简体   繁体   English

模块化OpenJDK11 Java映像在Linux上找不到动态库(例如libjava.so)

[英]Modular OpenJDK11 Java image can't find dynamic libraries (e.g. libjava.so) on Linux

I have compiled a modular Java application using OpenJDK 11.0.2 on Windows 10. I have downloaded the linux OpenJDK 11.0.2 jmods and I have used them to create a run-time image using jlink. 我已经在Windows 10上使用OpenJDK 11.0.2编译了模块化Java应用程序。我已经下载了Linux OpenJDK 11.0.2 jmods,并使用它们来使用jlink创建运行时映像。 I have copied the image to a CentOS 6.10 VM, and if I try to launch java (the one in the bin folder in of the image generated by jlink), it fails saying "Error: could not find libjava.so". 我已将映像复制到CentOS 6.10 VM,并且如果尝试启动Java(jlink生成的映像的bin文件夹中的一个),它将失败,提示“错误:找不到libjava.so”。 The libjava.so file is in the lib folder of the run-time image. libjava.so文件位于运行时映像的lib文件夹中。 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. 如果我将Java可执行文件移至/ usr / bin并将libjava.so移至/ usr / lib,它将抱怨找不到其他.so文件,因此我想这意味着它希望在以下目录中找到lib文件夹的内容/ usr / lib目录。 On Windows there is no such problem (ie if I create an image using the Windows jmod files). 在Windows上没有这样的问题(即,如果我使用Windows jmod文件创建映像)。 I'm reluctant to solve this problem by creating an installation script that creates tenths of symlinks, but I can't think of any other solution. 我不愿意通过创建一个安装脚本来解决这个问题,该脚本创建十分之一的符号链接,但是我想不出任何其他解决方案。 I have also tried to define a $JAVA_HOME variable that points to the [run-time image]/bin folder, but it still doesn't work. 我也尝试定义一个指向[运行时图像] / bin文件夹的$ JAVA_HOME变量,但是它仍然无法正常工作。

I did some more tests and I have found the reason for this misbehaviour. 我做了一些测试,发现了这种不当行为的原因。 The real problem was that I was using an output path (ie a value for the --output option) which ended with a directory called "bin" and this apparently causes Java to not find the dynamic libraries it needs, perhaps because it tries to locate them relative to the bin folder generated by jlink. 真正的问题是我使用的输出路径(即--output选项的值)以名为“ bin”的目录结尾,这显然导致Java找不到所需的动态库,也许是因为它试图找到它们相对于jlink生成的bin文件夹。 So, for example "--output bin" or "--output dist/bin" don't work, while for example "--output dist" or "--output bin/dist" work. 因此,例如“ --output bin”或“ --output dist / bin”不起作用,而例如“ --output dist”或“ --output bin / dist”起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM