install4j:如何获取当前正在执行的启动器的版本?

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

我目前的尝试是:

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

它有效,但我想知道是否有一种方法可以在不对当前工作目录做出任何假设的情况下获取信息?

可以查询sys.version编译器变量:

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

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