Search code examples
javaenvironment-variablesjnlpjava-web-start

Parsing Environment Variables as Arguments in JNLP File


I would like to know if there is a way of passing Windows environment variables as arguments in JNLP files?

I have a JNLP file in which I specify an argument that should be passed to the application's main method. If possible, I would like the argument to take the form %USERPROFILE%/dir/file. However, when I try to execute like this, webstart is taking userprofile as a literal value instead of replacing it with the environment variable.


Solution

  • The value of system property user.dir should be equivalent to %USERPROFILE% as an abstract file path. Instead of specifying file as a JNLP program argument, obtain it as follows:

    File file = new File(System.getProperty("user.dir"), "dir/file");