Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create Java runtime image on one platform for another using Jlink

I created runtime image using jlink on my Linux machine. And I see linux folder under the include folder. Does it mean that I can use this runtime image only for Linux platform? If yes, are there any ways to create runtime images on one platform for another (e.g. on Linux for Windows and vice versa)

like image 947
David Avatar asked Dec 01 '17 12:12

David


People also ask

How do I create a runtime image?

To create a custom Java runtime image for your application, run jlink before you package your application. Then pass the image produced to the packaging tool using the --runtime-image option.

What does jlink do?

Jlink is a Java command line tool that is used to generate a custom Java runtime environment (JRE). You can use your customized JRE to run Java applications. Using jlink, you can create a custom runtime environment that only includes the relevant class file.

What is Jlink distribution?

jlink is a tool that generates a custom Java runtime image that contains only the platform modules that are required for a given application. Such a runtime image acts exactly like the JRE but contains only the modules we picked and the dependencies they need to function.


1 Answers

The include directory is for header files, such as jni.h, that are needed when compiling C/C++ code that uses JNI and other native interfaces. It's nothing to do with jlink.

The jlink tool can create a run-time image for another platform (cross targeting). You need to download two JDKs to do this. One for the platform where you run jlink, the other for the target platform. Run jlink with --module-path $TARGET/jmods where $TARGET is the directory where you've unzipped the JDK for the target platform.

like image 96
Alan Bateman Avatar answered Sep 20 '22 16:09

Alan Bateman