• Post Reply Bookmark Topic Watch Topic
  • New Topic

Denying system.exit in java code  RSS feed

 
veerabahu Subramanian
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My objective is to nullifying the system.exit programmed. By goggling i learn t that this can be done by adding permission in policy file. But as far my google search i dont understand how to deny a permission. Most of them says about granting a permission. Can anyone clarify how to deny a permission.

Steps i tried.

Sample program: which does nothing other than calling system.exit(0) as the first line in main method.

added the following line to java.policy file in my

Also tried adding only
permission java.lang.RuntimePermission "exitVM";
to the already available grant block.
Also commented out

After that i understood that the default java policy file is java.home\lib\security\java.policy. So made all the change above mentioned there too.
But i could not achieve it. Can any one help me on this.

Win 2000/ Java1.4.2_12/no command line arguments while running the program.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The policy files are used only if the application is run with a security manager active (which, by default, the "java" command does not). How a security manager is activated is described here.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!