9

I am trying to convert an Windows installation of Java app created with Izpack to use JPackage provided In Java 14. The installer builds and installs, but when I try and run the exe it creates it fails, but gives no information about why it fails.

Is there a log or some way of finding out why it actually fails to start ?

Paul Taylor
  • 13,411
  • 42
  • 184
  • 351

1 Answers1

5

Use jpackage --win-console flag to enable console output, and run your app from CMD.exe so can see any output it writes.

However if you leave jpackage --win-console enabled, console output is ON for every other EXE you add with --add-launcher UNLESS the properties file for the launcher contains the line win-console which turns off console. It doesn't seem to work the other way around.

Its easier to work out what jpackage is doing by making the --main-class a Hello World / dump System properties + env.

DuncG
  • 12,137
  • 2
  • 21
  • 33
  • Thankyou that showed the issue, could not find main class, I had specified the package hierachy of --main-class option incorrectly. – Paul Taylor Jun 29 '20 at 11:07
  • I trying to create two launchers (one with --win-console and one without), Im confused about the launcher properties firle format is it meant to be win-console=--winconsole or win-console=true ectera ? – Paul Taylor Jul 10 '20 at 13:15
  • I want the default main launcher to have win-console disabled but to have a debug.exe version with it enabled, so far I can only get it the other way round ? – Paul Taylor Jul 10 '20 at 13:33
  • 1
    Maybe this issue will be fixed in JDK15+, but to have console in a launcher definition you have to set jpackage `--win-console` flag to make main-class have console, and add a line containing `win-console` by itself in each launcher.properties file to switch off that console for launcher EXE. That and the fact that I also found it hard to specify proper name of EXE for main class made me make --main-class a trivial / diagnostic app which prints to console and then use my pick of names + console per launcher EXE. – DuncG Jul 10 '20 at 15:27
  • My problem is that if I use jpackage --win-console then the --name param will be used by installer for name of application so this needs to be the expected name of main program, or can I get round this ? – Paul Taylor Jul 11 '20 at 06:39
  • Found a bug raised about --win-console but then closed saying there was no problem - https://bugs.openjdk.java.net/browse/JDK-8213717 – Paul Taylor Jul 11 '20 at 06:55
  • So I have tried Java 15EA - https://jdk.java.net/15/ and still doesnt work for me but im wondering if just doing wrong, help is a little confusing – Paul Taylor Jul 11 '20 at 07:50
  • That bug report did not explain the `--win-console` issue very well, but I suppose it is correct in the sense that yes you can control win-console setting for every main+launcher EXE. Its just not in a very obvious manner! – DuncG Jul 11 '20 at 09:32
  • I didn't find the `--name BLAH` setting very helpful as it applies same name to the Program Files install dir, the primary EXE and the name shown in Windows "Apps & features". I ended up adding console and no console launcher versions of each important app to have full control over the names and win-console settings of each, and only run the console versions when needing to track an issue. – DuncG Jul 11 '20 at 09:33
  • but didnt you want your non-console version of app to have same name as the package/installer ? – Paul Taylor Jul 11 '20 at 09:38
  • Doesnt that bug says he wants to run secondary launcher as console, and main app as not console and that does work ? – Paul Taylor Jul 11 '20 at 10:21
  • Posted a new question about this - https://stackoverflow.com/questions/62847475/with-jpackage-on-windows-is-it-possible-to-make-main-exe-not-run-as-console-bu – Paul Taylor Jul 11 '20 at 10:25
  • I'll post to other - the main exe is only one you have no control over if wanting control over the launcher consoles. – DuncG Jul 11 '20 at 11:04