This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds and have James Denton on-line!
See this thread for details.
Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Auto Exit the AppletViewer  RSS feed

 
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
 
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...
 
Rancher
Posts: 42975
76
  • 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: 42975
76
  • 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
Boost this thread!