How to tell if an applet or application is

I have this code inside a class that is used by my application and applet.

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

      

Unfortunately, when the applet loads this code, I get an error message because it cannot load the "extmapi" library.

To avoid this error, I need to know if the code I'm running is an applet or an application, so that I can:

if (isApplet)
    return;
else
    //load library

      

How do I know if I'm working inside the Applet?

+1


source to share


2 answers


Can't you just catch the (Security?) Exception?



+2


source


Your top-level container will be an Applet instance.



if (thispanel instanceof Applet)

      

+2


source







All Articles