javajpackage

How to correctly expose app-specific exit codes in jPackage-packaged application?


I have a command-line Java application that uses app-specific exit codes [System.exit(int)], and is packaged with jPackage. The exit codes, as well as precise output to stdout and stderr, are important and meaningful for callers of the application.

On one Windows machine, everything works as expected; the packaged .exe returns exit codes as expected (as reflected by %errorlevel%) when one of the non-zero exit codes is encountered. But on other Windows machines, the jPacakge executable is actually logging a (unwanted) message, Child process exited with code... and the actual process exit code is just 1 (no matter what actual exit code was used in System.exit().

I found this related OpenJDK bug about it, but it was supposedly fixed for version 19 and back-ported to 17.0.5 . We used OpenJDK 17.0.9 which came after the fix and back-port.

Why does only 1 machine do the correct thing, while 2 others still include the "Child process exited..." message?

Is there any way to avoid this to allow the Java exit codes to bubble up to callers of the .exe?


Solution

  • This appears to have been fixed as of OpenJDK 17.0.14.

    17.0.5 and 17.0.9 do NOT have the fix.