Reputation: 1652
I want to ship a single security policy file to our customers - for both Linux and Windows. In the java.security file, I add a line to point to our file, but due to path differences I have to specify it differently for Windows and Linux
policy.url.3=file:/${our.home}/lib/OurSecurity.policy # Windows
policy.url.3=file:${our.home}/lib/OurSecurity.policy # Linux
That first "/" after the "file:" is needed on windows since the variable our.home is defined as "C:\foo". I have the same problem in the policy file itself:
grant codeBase "file:/${our.home}/-" // Windows
grant codeBase "file:${our.home}/-" // Linux
I'm especially looking for a clever way to specify the codeBase in a platform independent way. By the way, redefining our.home is not really an option, as it's needed in a FilePermission clause.
Upvotes: 0
Views: 842
Reputation: 54084
Why would you want to use the same policy file?
JRE is different for Linux and for Windows so you should follow that and keep different versions for each installation.
IMO there is no issue of maintenance of having 2 files in this case.
Also I would suggest that you should focus your concern on the fact that a java update could delete your policy file.
Upvotes: 0
Reputation: 7952
If it were me, I would accept the fact that I needed different files and generate the linux version from the windows version by having a script to remove the "/".
However if you really need to use the same file, you could swap one pain for another by just defining another environment variable to represent the "/" on windows and have it blank on linux.
# our.hack = "/" on windows
# our.hack = "" on linux
policy.url.3=file:${our.hack}${our.home}/lib/OurSecurity.policy
Perhaps our.hack is not the best name in a production environment, but you get the idea. The variable is not used for anything else, so should not interfere with the rest of the app.
Upvotes: 1