• 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

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
 
He was expelled for perverse baking experiments. This tiny ad is a model student:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic