Jarrett Spiker
Jarrett Spiker

Reputation: 401

Have Install4j installer display --version info

I create a set of installers with install4j, and would like a quick way to check the version info of the installer executable

Traditionally, this would involve calling something like installer-name.sh --version

Ideally, this would work without needing to unpack the bundled JRE, but I notice that even the -h help for install4j installers unpacks the JRE, so I am assuming that is not an option...

What I'd like to know is:

==============

To be clear what I mean by the last point is that I would like a solution like (framing install4j installation actions as a Java function):

if(versionRequested){
  printVersion();
  return;
}
//all the rest of my installation actions

rather than:

if(versionRequested){
  printVersion();
}
else{
  //all the rest of my installation actions
}

Upvotes: 1

Views: 398

Answers (1)

Ingo Kegel
Ingo Kegel

Reputation: 48070

In the "Startup" node of the installer, add a "Run script" action with the script

if (Arrays.asList(context.getExtraCommandLineArguments()).contains("--version")) {
    System.out.println("Version " + context.getCompilerVariable("sys.version"));
    context.finish(0);
}
return true;

On Windows, System.out.println will not print to the console, because the installer is a GUI application, so you would have to call

Util.showMessage("Version " + context.getCompilerVariable("sys.version"));

which also behaves correctly in console mode.

Upvotes: 1

Related Questions