2

I'm trying to generate the Windows bundle of my JavaFX application using JPackage. I'm running on Liberica JDK 19 and my scripts first generate a runtime using JLink with a --vm=client argument and then they run jpackage with a --runtime-image pointing to the generated image.

Everything runs fine when I launch the application generated by jpackage using a .bat script, but when I run the the generated .exe I get an error and, looking at the debug information, it seems the .exe is loading the jvm.dll from the runtime\bin\server instead of the runtime\bin\client folder:

[TRACE] app.cpp:123: Entering app::launch
[TRACE] AppLauncher.cpp:116: Launcher config file path: "C:\delete\pdfsam-5.0.0-SNAPSHOT-windows\pdfsam\app\pdfsam.cfg"
[TRACE] JvmLauncher.cpp:44: Jvm(000001319907E960)::Jvm()
[TRACE] AppLauncher.cpp:76: Property "app.runtime" not found in "Application" section of launcher config file. Using Java runtime from "C:\delete\pdfsam-5.0.0-SNAPSHOT-windows\pdfsam\runtime" directory
[TRACE] JvmLauncher.cpp:49: Jvm(000001319907E960)::~Jvm()
[TRACE] app.cpp:123: Entering app::launch
[TRACE] AppLauncher.cpp:116: Launcher config file path: "C:\delete\pdfsam-5.0.0-SNAPSHOT-windows\pdfsam\app\pdfsam.cfg"
[TRACE] JvmLauncher.cpp:44: Jvm(00000200C91AE310)::Jvm()
[TRACE] AppLauncher.cpp:76: Property "app.runtime" not found in "Application" section of launcher config file. Using Java runtime from "C:\delete\pdfsam-5.0.0-SNAPSHOT-windows\pdfsam\runtime" directory
[TRACE] WinLauncher.cpp:216: SetDllDirectory to: C:\delete\pdfsam-5.0.0-SNAPSHOT-windows\pdfsam\runtime\bin
[TRACE] WinLauncher.cpp:73: Entering `anonymous-namespace'::loadDllWithAddDllDirectory
[TRACE] WinLauncher.cpp:89: AddDllDirectory(C:\delete\pdfsam-5.0.0-SNAPSHOT-windows\pdfsam\runtime\bin): OK
[TRACE] WinLauncher.cpp:97: LoadLibraryEx(C:\delete\pdfsam-5.0.0-SNAPSHOT-windows\pdfsam\runtime\bin\jli.dll, LOAD_LIBRARY_SEARCH_DEFAULT_DIRS): 00007FFCCB100000
[TRACE] WinLauncher.cpp:0: Exiting `anonymous-namespace'::loadDllWithAddDllDirectory (entered at WinLauncher.cpp:73)
[TRACE] WinLauncher.cpp:73: Entering `anonymous-namespace'::loadDllWithAddDllDirectory
[TRACE] WinLauncher.cpp:0: Exiting `anonymous-namespace'::loadDllWithAddDllDirectory (entered at WinLauncher.cpp:73)
[TRACE] WinLauncher.cpp:52: Entering `anonymous-namespace'::loadDllWithAlteredPATH
[TRACE] WinLauncher.cpp:62: New value of PATH: SOME PATH HERE;C:\delete\pdfsam-5.0.0-SNAPSHOT-windows\pdfsam\app;C:\delete\pdfsam-5.0.0-SNAPSHOT-windows\pdfsam\runtime\bin\server
[TRACE] WinLauncher.cpp:0: Exiting `anonymous-namespace'::loadDllWithAlteredPATH (entered at WinLauncher.cpp:52)
[TRACE] JvmLauncher.cpp:49: Jvm(00000200C91AE310)::~Jvm()
[ERROR] app.cpp:179: Exception with message 'WinDll.cpp(40) at `anonymous-namespace'::loadLibrary(): LoadLibraryW(C:\delete\pdfsam-5.0.0-SNAPSHOT-windows\pdfsam\runtime\bin\server\jvm.dll) failed. System error [126](system error 126 (Impossibile trovare il modulo specificato))' caught
LoadLibraryW(C:\delete\pdfsam-5.0.0-SNAPSHOT-windows\pdfsam\runtime\bin\server\jvm.dll) failed. System error [126](system error 126 (Impossibile trovare il modulo specificato))
[TRACE] app.cpp:0: Exiting app::launch (entered at app.cpp:123)

Any idea what I might be doing wrong?

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Andrea Vacondio
  • 888
  • 9
  • 19
  • Does it work without the argument`--vm=client`? – jewelsea Jan 30 '23 at 00:36
  • Yes it works. The generated runtime has a `server` directory and the application starts – Andrea Vacondio Jan 30 '23 at 11:15
  • Which jdk-19 are you using? That setting just gives an error message for me: `jlink --vm=client --add-modules java.base --output myruntime`. – DuncG Jan 30 '23 at 18:02
  • I'm using Liberica and you are right, using Oracle jdk the `--vm=client` gives an error while without it it seems to default to the `server` value (lib subirectory only contains the server version). With Liberica, leaving the parameter out it generates `server`, `client` and `minimal`. – Andrea Vacondio Jan 31 '23 at 09:25

1 Answers1

3

Don't use the jlink option:

--vm=client

At least for Oracle JDK, and probably for other JDK distributions as well, the client VM is no longer part of the distribution:

In Oracle Java Runtime Environment (JRE) 8 and earlier, different implementations of the JVM, (the client VM, server VM, and minimal VM), were supported for configurations commonly used as clients, servers, and for embedded systems. As most systems can now take advantage of the server VM, the Oracle Java Runtime Environment (JRE) 9 provides only that VM implementation.

The jlink documentation states:

Plug-ins not listed in this section aren't supported and are subject to change.

The vm plugin isn't listed in the documentation, so it really should not be used.

jewelsea
  • 150,031
  • 14
  • 366
  • 406
  • Thanks, that's helpful. Also quoting my comment in reply to @DuncG comment: I'm using Liberica... using Oracle jdk the `--vm=client` gives an error while without it it seems to default to the `server` value (lib subirectory only contains the server version). With Liberica, leaving the parameter out it generates `server`, `client` and `minimal`. – Andrea Vacondio Jan 31 '23 at 09:28