Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jlink --vm parameter #117

Open
torakiki opened this issue Jan 31, 2023 · 1 comment
Open

jlink --vm parameter #117

torakiki opened this issue Jan 31, 2023 · 1 comment

Comments

@torakiki
Copy link

Following up this SO question, it seems that jlink from Liberica behaves differently from the one in Oracle JDK or in Temurin. Using version 19 and running the command jlink --add-modules java.base --output ./out generates a vm that contains client, server and minimal in its lib subdirectory. Running the same command in Oracle JDK or Temurin it only generates server.
You can get the same result with Liberica by using the argument --vm=server but, as pointed out in the SO replies, the vm argument shouldn't be used.
To add some context, I was using Temurin and switched to Liberica for my JavaFX app. I realized the jlinked image was bigger because it contained those lib subdirectory and I ended up using --vm=client. Used jpackage pointing to the generated jvm to package my application and the .exe generated by jpackage fails to run.

@morgion
Copy link
Collaborator

morgion commented Feb 6, 2023

Hello,

Different OpenJDK distributives provide different set of VMs, so you should use --vm option to get the expected result. Liberica JDK offers three VMs (Server, Client, Minimal) on some platforms, as well as additional components - OpenJFX, etc.
Also there are other components included in the Full version of Liberica JDK (read this as 'full of features - there are Client and Minimal VM + OpenJFX' and other necessary dependencies). If you use another OpenJDK distributive, and do not need to pass --vm, that only means that on this platform the other distributive does not offer Client and Minimal VM.
jlink allows you to create custom image with any VM and set of jmods. You can control content of your image to add any VM from Liberica Full bundle. By default jlink adds all VMs that are in the base image (see jlink --list-plugins:

  --vm <client|server|minimal|all>
                            Select the HotSpot VM in the output image.
                            Default is all

)

You can use it your own way and add any VM to resulting image. If you would like to get only Client or Server, add --vm client or --vm server options. Original question on SO mentioned that you use jpackage to create application, maybe the problem is with the application itself or with jpackage, we can investigate deeper if you provide a minimal example how to reproduce the issue - especially the options passed to jpackage and jlink you're using to create the image.

Also you can use the following options to control result image:

--jlink-options <jlink options>
          A space separated list of options to pass to jlink
          If not specified, defaults to "--strip-native-commands
          --strip-debug --no-man-pages --no-header-files".
          This option can be used multiple times.
  --java-options <java options>
          Options to pass to the Java runtime
          This option can be used multiple times.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants