In the properties files, you can use the standard (Java) syntax template $ {java.home}, and then replace it with Runtime with the value System.getProperty("java.home"); . Therefore, in your file, instead of:
certificate=%JAVA_HOME%\certs\myselffign.cer (Windows) certificate=$JAVA_HOME\certs\myselffign.cer (*nix)
Just use the standard:
certificate=${java.home}/certs/myselfsign.cer
And in the code something like:
String javaHomePath = System.getProperty("java.home")l Properties props = Properties.load( ...); String certFilePath = props.get("certificate"); certFilePath = certFilePath.replaceAll("${java.home}", javaHomePath);
Remember that using the standard template syntax, you can also use some of the open source property replacement tools. Like Spring PropertyResolver. Hope this helps.
source share