This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Auto Exit the AppletViewer

 
Koh Khai Huat
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

regards
KKH
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Koh Khai Huat
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

regards
KKH
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Koh Khai Huat
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,
KKH
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic