4

The following small Java program and jpackage command create an app-image which when launched on Windows 10 launches multiple exe's. This does not happen before JDK 17. The same code and command using the JDK 16 jpackage results in only a single instance of Main.exe running in the Task Manager Details tab. Issue appears to still happen in JDK 18 and 19.

import javax.swing.*;

public class Main {
    public static void main(String[] args) {
        JDialog dialog = new JDialog();

        dialog.setVisible(true);
    }
}

jpackage --type app-image --input jpackage_test_jar --dest install/tmp --main-jar jpackage_test.jar --main-class Main

Result (Main.exe twice in Task Manager Details)

Tested the same code and jpackage command on JDKs 15, 16, 17, 18 and 19. Multiple exe's are launched on Windows 10 in JDKs 17, 18 and 19, but not in 15 or 16. JDK 15 was from AdoptOpenJDK, the rest were Eclipse Temurin from Eclipse Adoptium.

aauclair
  • 41
  • 1
  • 1
    Perhaps check JDK bug db. I see same as you - Task manager lists a duplicated exe via JDK20-jpackage, no duplicated exe on JDK14-jpackage for exact same packaged code. Following `ProcessHandle.current().parent() ...` shows extra value, a parent with same command "someapp.exe" but which isn't visible to `jps` or `jstack` so isn't a JVM. – DuncG Jan 19 '23 at 17:21
  • I use Eclipse Adoptium JDK 17 + JPackage to package it into a .msi file. After the installation is complete, a startup shortcut will be generated on the desktop. No matter whether you click the startup shortcut or directly click the app exe, there will not be multiple exe executions. My program UI is using Eclipse SWT, not SWING package. – life888888 Jan 20 '23 at 06:37
  • I've been unable to find anything on the JDK bug db for this issue. Tried to look for quite a while before writing this question. I just removed Swing entirely and just added a large sleep. The app still creates multiple exe's. Unfortunately I can't use jpackage to build an installer. We use app-image to generate executables that we then add to our own installer because we have multiple Java Swing UIs together in a single installer (plus tons of C++ apps). – aauclair Jan 20 '23 at 12:49
  • Yes it's not related to Swing: I made my check using my own app deployment, not your example above. – DuncG Jan 20 '23 at 16:55

1 Answers1

0

I see you created an issue for this: https://bugs.openjdk.org/browse/JDK-8301247

As a possible workaround, since you're building an image, and then building an installer from that, you could swap out the executable with one that's made with a previous version of jpackage before you build the installer. In fact, you can use any older one. Just rename it appropriately and it should work.

Dean Wookey
  • 181
  • 2
  • 4
  • I don't think it's a big enough issue to do that. From your comments on the bug report, it sounds like we have the same issue with it. If the parent process exits, we get popups about the child process exiting. – aauclair Jul 24 '23 at 13:03