代码之家  ›  专栏  ›  技术社区  ›  michelemarcon

如何知道是applet还是application

  •  1
  • michelemarcon  · 技术社区  · 17 年前

    我在一个应用程序和小程序使用的类中有这个代码。

    static
    {
        if (System.getProperty("os.name").startsWith("Windows"))
        {
            System.loadLibrary("extmapi");
        }
    }
    

    不幸的是,当小程序加载此代码时,我会收到一个错误,因为它无法加载“extmapi”库。

    为了避免这个错误,我需要知道我运行的代码是小程序还是应用程序,这样我可以:

    if (isApplet)
        return;
    else
        //load library
    

    我怎么知道我是否在小程序中运行?

    2 回复  |  直到 13 年前
        1
  •  2
  •   Somatik    17 年前

    你就不能抓住(保安)吗?例外?

        2
  •  2
  •   JTeagle    17 年前

    您的顶级容器将是小程序的一个实例。

    if (thispanel instanceof Applet)