The only values that are automatically substituted by the web server in jnlp files are:
- $$codebase- The URL of the request except for the name of the JNLP file
- $$name The name of the JNLP file
- $$context The base URL of the web application
- $$site The web server address
- $$hostname The name of the server
These substitutions only happen if using the JNLPDownloadServlet in a servlet container.
The host cannot possibly know the value of the user home parameter when it downloads the JNLP file.
If you are deploying a JNLP that can be run as standalone, and you need to load arguments to the application I would recommend using a properties file at a specific location with defaults for when the file does not exist (the application can dynamically create the properties file the first time it runs or you could use an installer to do so).
Here is a detailed example:
public class Main {
public static void main(String ... args) throws IOException{
new Main();
}
private static Properties instance;
public static Properties getProperties(){
return instance;
}
private static Properties defaultProperties(){
// implement default properties here
Properties props = new Properties();
props.setProperty("myApp.property1","someDefaultValue");
return props;
}
public static void createDefaultPropsFile(File propsFile,Properties props) throws IOException {
propsFile.getParentFile().mkdirs();
props.store(new FileWriter(propsFile),"My App Properties");
}
private Main() throws IOException{
File appDir = new File(System.getProperty("user.home"), "myApp");
// find property file
File propsFile = new File(appDir, "settings.properties");
Properties appProperties = new Properties(defaultProperties());
if(!propsFile.exists()){
createDefaultPropsFile(propsFile,appProperties);
} else {
appProperties.load(new FileReader(propsFile));
}
// this should really be done using a singleton or something similar
instance = appProperties;
System.out.println("Property"+getProperties().getProperty("myApp.property1"));
}
}