Search code examples
install4j

Suppress GUI Mode in install4j for Linux Installer While Allowing GUI Mode for Windows Installer


We are using install4j to generate a Windows and a Linux installer for our application. We would like our users to use the GUI mode for installations on Windows and the console mode for installations on Linux.

This works by passing the -c parameter to the installer, I know. But I would also like to suppress the usage of the GUI mode for Linux. Similarly to the "Disable console mode on Windows" option in the installer settings. Is there something I did not see, that enables this behavior?

If there is no option to suppress this, we will add an action to the installer to quit if it was started from Linux and is in GUI mode.


Solution

  • As of install4j 8.0.8 there is no way to prohibit the GUI mode, you would indeed have to add a "Run script" action with the script

    !(Util.isLinux() && context.isGui())
    

    and set its "Failure strategy" property to "Quit on Failure" and its "Error message" property to "GUI mode not allowed" or something similar.

    There is also a "Default execution mode" property on the Installer, you can right-click it, select "Switch to text mode" from the context menu and set the text field to

    ${compiler:executionMode}
    

    Then, define a compiler variable on "General Settings->Compiler Variables" named "executionMode" with the value "GUI". In the media wizard of the Linux media file, go to the "Customize project defaults->Compiler Variables" step and override the "executionMode" compiler variable with the value "CONSOLE".

    Then your users do not have to pass -c as the argument on Linux.


    Update: As of 8.0.8 there is a bug in install4j that prevents the replacement of compiler variables for this property. It will be fixed in 8.0.9.