Win a copy of Spark in Action this week in the Open Source Projects 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:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Is it possible to put policy file in program?

 
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
 
High Plains Drifter
Posts: 7289
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
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic