install4j: How can I get the version of the currently executing launcher?

Viewed 22

My current attempt is:

    File executionDir = new File("").getCanonicalFile();
    ApplicationInfo info = ApplicationRegistry.getApplicationInfoByDir(executionDir);
    return info.getVersion();

It works, but I wonder if there is a way to get at the information without making any assumptions about the current working directory?

1 Answers

You can query the sys.version compiler variable:

import com.install4j.api.launcher.Variables.Variables;

try {
    String version = Variables.getCompilerVariable("sys.version");
} catch (IOException e) {
    // TODO not running in installation
}
Related