JDK-8219703 : Image created with jlink can't find dynamic libraries on Linux
  • Type: Bug
  • Component: tools
  • Sub-Component: jlink
  • Affected Version: 11.0.2
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux
  • CPU: x86
  • Submitted: 2019-02-21
  • Updated: 2019-03-02
  • Resolved: 2019-03-02
Related Reports
Duplicate :  
Description
ADDITIONAL SYSTEM INFORMATION :
CentOS 6.10 64-bits, Oracle OpenJDK 11.0.2

A DESCRIPTION OF THE PROBLEM :
I have compiled a modular application on Windows 10 using Java SE 11.0.2. I have downloaded the Linux 64-bits jmods and I have used them to create a run-time image. I have copied the image to a CentOS 6.10 64-bits VM where there was no Java installed. When I launch the java executable it fails saying "Error: could not find libjava.so". The libjava.so file is in the lib folder of the run-time image. If I move the java executable to /usr/bin and the libjava.so to /usr/lib, it complains about not finding a different .so file, so I guess this means that it expects to find the contents of the lib folder in the /usr/lib directory. On Windows there is no such problem (i.e. if I create an image using the Windows jmod files, the java executable starts without problems). This behaviour defeats the purpose of creating a self-contained image 

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1 - Create a modular application using Oracle OpenJDK 11.0.2
2 - Compile it on Windows 10
3 - Download the Oracle OpenJDK 11.0.2 Linux 64-bits jmods
4 - Use the Linux jmods to create a run-time image with jlink
5 - copy the image to a CentOS 6.10 64-bits VM
6 - run the application (or simply execute java -version)

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Java starts
ACTUAL -
Java does not start, the error is "Error: could not find libjava.so"

FREQUENCY : always



Comments
Additional Information from Submitter: ------------------------------------------------------ It turns out that problem is due to the name of the output path specified in the --output option of jlink . I have opened a separate bug JDK-8219962) to track the issue. ------------------------------------------------------ Based on Submitter's response, closing this as duplicate of JDK-8219962
02-03-2019

When created separate custom run-time image with jlink on windows and Linux using OpenJDK 11.0.2, I could not find any issue. I can run the java application for both Windows and Linux. Steps for Windows OS: ----------------------------- >D:\jlink-example>javac -d out src\module-info.java >D:\jlink-example>javac -d out --module-path out src\com\logicbig\example\Test.java >D:\jlink-example>jlink --module-path D:\java\jdk-11\jmods;out --add-modules test.example --output build >D:\jlink-example\build\bin>java.exe --module test.example/com.logicbig.example.Test Feb 26, 2019 12:50:12 AM com.logicbig.example.Test main INFO: Running test application.. Similarly, ran successfully in Ubuntu. But the submitter is creating Linux run-time image on Windows and then copying it to CentOS. Self-contained application packages must be built on the operating system on which it is intended to run. In my opinion, this seems to be Not an issue.
26-02-2019