• Post Reply Bookmark Topic Watch Topic
  • New Topic

Is it possible to put policy file in program?  RSS feed

 
Peter Gates
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all
When starting a server, normally I need to type: java -Djava.security.policy=fbn.policy XXXXXX.
I just wondering if I can put the fbn.policy into a java file, say fbn.java, so that I can start the server like java XXX?
Thanks for any help.
Peter
 
Michael Ernest
High Plains Drifter
Sheriff
Posts: 7292
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Peter -
You can assign java.security.policy a value within the server source if you want:
...
Properties props = System.getProperties();
props.put("java.security.policy", "fbn.policy");
...
This hard-codes the policy by name, so if you want multiple policies without editing the same file for each use:
props.put("java.security.policy", args[0]);
where arg[0] is a command-line parameter instead of a directive (-D thingy).
------------------
Michael Ernest, co-author of: The Complete Java 2 Certification Study Guide
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!