JDK-8340311 : JPackage app-image exe launches multiple exe's in JDK 22+
  • Type: Enhancement
  • Component: tools
  • Sub-Component: jpackage
  • Affected Version: 18,22
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows
  • CPU: generic
  • Submitted: 2024-09-11
  • Updated: 2024-11-11
  • Resolved: 2024-11-02
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 24
24 b23Fixed
Related Reports
Relates :  
Relates :  
Description
ADDITIONAL SYSTEM INFORMATION :
OpenJDK 22 on Windows 11

A DESCRIPTION OF THE PROBLEM :
Current revisions of jpackage generate exe launchers for Windows that by design always spawn 2 instances:
https://bugs.openjdk.org/browse/JDK-8272328

The reason for this is adding the "app" folder to the java.library.path by default, which can only be done via the %PATH% environment variable due to jli internals, but %PATH% cannot be changed for the current process due to Windows internals, so the process starts another instance with a slightly altered environment. This is clunky, but acceptable *if* auto-adding "app" folder to the java.library.path were indeed necessary. However, it's not necessary if there's no *.dll files in the "app" folder, it's not necessary if java.library.path is set via java-options already, etc.

The "first instance starts second instance which then launches the application" behavior is especially odd for win-console exe launchers since the first console exe will wait for the second console exe to finish before they can both exit.

I would like to request a way to disable this "restart" behavior since it doesn't do anything for me.

I would recommend checking the java-options= list and for a java.library.path= entry and then not do the "restart" behavior if the developer has already manually set the library path correctly.

REGRESSION : Last worked in version 16

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
jpackages should generate exe files that (if possible) only spawn 1 process
ACTUAL -
exe files generated by jpackage spawn 2 processes

FREQUENCY : always



Comments
Changeset: 29882bfe Branch: master Author: Alexey Semenyuk <asemenyuk@openjdk.org> Date: 2024-11-02 12:44:17 +0000 URL: https://git.openjdk.org/jdk/commit/29882bfe7b7e76446a96862cd0a5e81c7e054415
02-11-2024

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/21726 Date: 2024-10-26 01:16:05 +0000
30-10-2024

Checking the contents of `java-options=` for a `java.library.path=` entry would mean implementing parser of the standard Java launcher command line in jpackage app launcher. Instead I suggest to add a new `win.norestart` boolean property in .cfg file. If the property is set to `yes`, the launcher will not alter %PATH% env variable and will not restart itself. As a quick fix `win.norestart` boolean property can be supported in jpackage app launcher without adding support to configure it through jpackage CLI. Users will have to manually add `win.norestart=yes` to .cfg files. Support for configuring this option through jpackage CLI will require filing a CSR.
17-09-2024

Moved to JDK as an enhancement for further evaluations.
17-09-2024