tags:

views:

101

answers:

2

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

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

Unfortunately, when the applet loads this code I get an error, because it can't 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 do:

if (isApplet) return; else //load library

How can I know if I'm running inside an Applet?

+2  A: 

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

Somatik
+1  A: 

Your top-level container will be an instance of Applet.

if (thispanel instanceof Applet)
JTeagle