Search code examples
javaantbundlelaunch4j

Lauch4j .ini file specify jre path


I am using Launch4j with a bundled jre version. The path of the jre version has to be configurable, so I though using the .ini file. I don't understand the documentations on the launch4j website, so I'm coming here for help.

Here is the part of my launch4j config:

<jre minVersion="1.6.0">
    <path>%JRE_PATH%</path>
    <jdkPreference>preferJre</jdkPreference>
</jre>

and this is in my myapp.l4j.ini:

-JRE_PATH="D:\builds\jre"

But the exe file always says:

This application was configured to use a bundled Java Runtime Enviroment but the runtime is missing or corrupted

The JRE_PATH variable should be added into the path-element at runtime.

What am I doing wrong?


Solution

  • I took a look at launch4j documentation for its configuration file and also for additional JVM options (which is where xxx.l4j.ini is mentioned).

    I think you are misunderstanding what you can do with the .ini file. I think it is just intended as a place where you can specify runtime JVM options (e.g. -D and -X args) for your application. I don't think it's a general purpose variable declaration file.

    I don't think that it is valid to use an environment variable in the XML configuration file (%JRE_PATH%). The documentation says this should be a relative or absolute path. I don't think variable substitution is supported in the XML configuration file.