Forums Register Login
Auto Exit the AppletViewer
Hi Guys,

I got a game running on a appletviewer. and i would like the applet to exit by it self when the game finish. I would like to ask if any of u guys know any method or command that i can invoke in the java code to exit the applet. Please let me know thanks in advance

Take in mind that an applet typically is displayed inside a HTML page. What would it mean for an applet "to exit" in that context?

Moving to our Applet forum...
The System.exit call will quit the appletviewer, like it does with any other Java application. After all, the appletviewer is (for the most part) just another Java application.
Hi Ulf Dittmer,

Thanks For Yr Post but when i call System.exit(0); the program game me this exception => "java.security.AccessControlException: access denied (java.lang.RuntimePermission exitVM)"

Do u know why this exception is thrown and how to get the access to exit my appletViewer?

Many Thanks In Advance

Ah! appletviewer actually enforces the applet security restrictions - that wasn't always the case. Create a file (say, 'applet.policy') containing the following in your applet directory:

If you then run the appletviewer by

appletviewer -J-Djava.security.policy=applet.policy applet.html

it will use the file as security policy file. What that does is to allow the applet to call System.exit. There's more information about how this works in the FAQ: HowCanAnAppletReadFilesOnTheLocalFileSystem.

By the way, please don't use abbreviations like "u" and "yr" in your posts. They're OK for text messaging, but in a forum like this, where many people do not speak English as a native language, and have a hard enough time following what's being said as it is, they're not appropriate.
[ March 16, 2006: Message edited by: Ulf Dittmer ]
hi Ulf Dittmer,

Thanks for your comment and it help me alot Thanks. As for the "yr" and "u" I apologize for that and will try my best not to make that mistake again

best regards,
Enjoy the full beauty of the english language. Embedded in this tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database

This thread has been viewed 1397 times.

All times above are in ranch (not your local) time.
The current ranch time is
Feb 21, 2019 13:11:44.