1

We have packaged our application with jpackage and it works nicely.

Somehow someone inadvertently deleted the main jar from the installation directory. Since then the '.exe' failed to launch (obviously). Problem is it didn't show any kind of error message, so it took us a while to realize what was wrong.

Is there some way to have the exe show at least some useful error message?

geert3
  • 7,086
  • 1
  • 33
  • 49

1 Answers1

3

Problems with the EXE generated by jpackage can be easier to diagnose if you activate the console with jpackage --win-console parameter.

You might not want to do this for the main app EXE, so instead you could distribute your application with a second launcher which has the console enabled and same main-class. Just create a new file appwithconsole.properties and use:

jpackage --add-launcher debugversion=appwithconsole.properties ... rest of command line.

appwithconsole.properties

main-class=as.used.in.command.line
win-console=true

Then try debugversion.exe after deleting the jar, it should report the error more clearly than the EXE without console:

Error: Could not find or load main class ...
DuncG
  • 12,137
  • 2
  • 21
  • 33
  • It's true that we don't want console option for the main exe, but all in all having a second exe to diagnose issues is a rather elegant solution, and likely the only real solution for the moment. Thanks – geert3 Nov 01 '20 at 20:34
  • 1
    Note that `--add-launcher` does not work in JDK15 jpackage, but is OK in JDK14 or 16EA – DuncG Dec 21 '20 at 12:44
  • Is there a more official source for `--add-launcher` being broken in Java 15? I'm experiencing that, and this comment is the only thing I can find confirming that I'm not crazy. – Tim Mar 11 '21 at 16:12
  • Yes, it was filed as [https://bugs.openjdk.java.net/browse/JDK-8253426]. You should be OK using jpackage from either JDK14 or 16EA with your JDK15 build files if not wanting to fully upgrade or downgrade, and proper JDK16 is due soon. – DuncG Mar 11 '21 at 16:25