Is it possible to check if running as applet or application?

A

anywherenotes

Hello,

Is it possible for a class - which is not the same as init()/main()
class - to check if it's running as an applet or application?

Thank you
 
A

Arne Vajhøj

Is it possible for a class - which is not the same as init()/main()
class - to check if it's running as an applet or application?

You could generate a stack trace and check it for Applet/JApplet.

For some purposes checking whether a SecurityManager has been
set would work.

Arne
 
D

Daniel Pitts

Hello,

Is it possible for a class - which is not the same as init()/main()
class - to check if it's running as an applet or application?

Thank you
What is your real goal? Why is this information helpful?
 
L

Lothar Kimmeringer

Is it possible for a class - which is not the same as init()/main()
class - to check if it's running as an applet or application?

untested:
if (new Applet().getAppletContext() == null){
// not an applet
}
else{
// inside an applet
}

Maybe the creation of an Applet ouside an Applet-container throws
an exception already, so this might work as test as well.


Regards, Lothar
--
Lothar Kimmeringer E-Mail: (e-mail address removed)
PGP-encrypted mails preferred (Key-ID: 0x8BC3CD81)

Always remember: The answer is forty-two, there can only be wrong
questions!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,438
Messages
2,571,699
Members
48,796
Latest member
Greg L.
Top