Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Wanted: Help Creating policy file

 
Siegfried Heintze
Ranch Hand
Posts: 408
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to follow this tutorial and I'm confused about the file name of the policy file.

Below is the code that goes into the policy file (from the above URL). Now Where do I put it on a windows machine? %HOMEDRIVE%%HOMEPATH%? What do I specify as the keystore?

How do I edit it for a windows machine running cygwin?

If I type



it says "bad substitution" at the cygwin bash prompt.



Thanks,
Siegfried
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First off, "user.home" is an identifier that's understood by the JVM, not something the shell would know about. So I'm not surprised cygwin doesn't like it. The user's home directory is the one denoted as "~" in Unix; "echo ~" should tell you what it is.

You can name the file anything you want, since you need to pass the filename to the JVM process through the "java.security.policy" runtime parameter, as shown in the page you linked to.
 
Siegfried Heintze
Ranch Hand
Posts: 408
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I specify the keystore, is there a way I can avoid hard coding "/home/ray/keystore/" on line two? I'd like to do it in a way that OS neutral.

Perhaps the answer is to use "${user.home}/keystore" on line 2?

Let me ask the question in a broader way:

Why do I see a "$" on line 12 but not on line 10? In both cases, we are expanding a java property called user.home. Can someone point me to the documentation where it describes when and how properties are expanded in the properties file.
Thanks,
Siegfried
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do I see a "$" on line 12 but not on line 10? In both cases, we are expanding a java property called user.home.

Line 10 does not expand anything. "user.home" on that line is not a property - it is the name of a permission that is being granted. It just happens to be called the same as a certain system property (and is of course related to it).

If you read the javadocs for PropertyPermission and FilePermission the difference should become clear.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic