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.
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.
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.