![找不到 libjli.so。如何在没有root权限的情况下安装java?](https://linux22.com/image/171431/%E6%89%BE%E4%B8%8D%E5%88%B0%20libjli.so%E3%80%82%E5%A6%82%E4%BD%95%E5%9C%A8%E6%B2%A1%E6%9C%89root%E6%9D%83%E9%99%90%E7%9A%84%E6%83%85%E5%86%B5%E4%B8%8B%E5%AE%89%E8%A3%85java%EF%BC%9F.png)
我想在一个简单的网络托管服务器上运行java,我可以通过ssh访问该服务器,但没有root权限。我已经下载并解压了 jdk linux/x64 tarball 但运行 java 二进制文件然后产生
jdk-14.0.1/bin/java: error while loading shared libraries: libjli.so:
cannot open shared object file: No such file or directory
该文件libjli.so
位于jdk-14.0.1/lib
子目录中,但 java 二进制文件似乎无法找到它。
运行strace jdk-14.0.1/bin/java
产量:
execve("jdk-14.0.1/bin/java", ["jdk-14.0.1/bin/java"], [/* 17 vars */]) = 0
brk(0) = 0x7fa16e241000
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fa16d87c000
readlink("/proc/self/exe", 0x7fffb04bc970, 4096) = -1 ENOENT (No such file or directory)
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=24961, ...}) = 0
mmap(NULL, 24961, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fa16d875000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/tls/x86_64/libz.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/lib/x86_64-linux-gnu/tls/x86_64", 0x7fffb04bd280) = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/tls/libz.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/lib/x86_64-linux-gnu/tls", 0x7fffb04bd280) = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/x86_64/libz.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/lib/x86_64-linux-gnu/x86_64", 0x7fffb04bd280) = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/libz.so.1", O_RDONLY) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\340#\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=92752, ...}) = 0
mmap(NULL, 2187792, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fa16d448000
mprotect(0x7fa16d45e000, 2093056, PROT_NONE) = 0
mmap(0x7fa16d65d000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x15000) = 0x7fa16d65d000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/libjli.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/x86_64-linux-gnu/tls/x86_64/libjli.so", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/usr/lib/x86_64-linux-gnu/tls/x86_64", 0x7fffb04bd250) = -1 ENOENT (No such file or directory)
open("/usr/lib/x86_64-linux-gnu/tls/libjli.so", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/usr/lib/x86_64-linux-gnu/tls", 0x7fffb04bd250) = -1 ENOENT (No such file or directory)
open("/usr/lib/x86_64-linux-gnu/x86_64/libjli.so", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/usr/lib/x86_64-linux-gnu/x86_64", 0x7fffb04bd250) = -1 ENOENT (No such file or directory)
open("/usr/lib/x86_64-linux-gnu/libjli.so", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/usr/lib/x86_64-linux-gnu", {st_mode=S_IFDIR|0755, st_size=36864, ...}) = 0
open("/lib/tls/x86_64/libjli.so", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/lib/tls/x86_64", 0x7fffb04bd250) = -1 ENOENT (No such file or directory)
open("/lib/tls/libjli.so", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/lib/tls", 0x7fffb04bd250) = -1 ENOENT (No such file or directory)
open("/lib/x86_64/libjli.so", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/lib/x86_64", 0x7fffb04bd250) = -1 ENOENT (No such file or directory)
open("/lib/libjli.so", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/lib", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
open("/usr/lib/tls/x86_64/libjli.so", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/usr/lib/tls/x86_64", 0x7fffb04bd250) = -1 ENOENT (No such file or directory)
open("/usr/lib/tls/libjli.so", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/usr/lib/tls", 0x7fffb04bd250) = -1 ENOENT (No such file or directory)
open("/usr/lib/x86_64/libjli.so", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/usr/lib/x86_64", 0x7fffb04bd250) = -1 ENOENT (No such file or directory)
open("/usr/lib/libjli.so", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/usr/lib", {st_mode=S_IFDIR|0755, st_size=20480, ...}) = 0
writev(2, [{"jdk-14.0.1/bin/java", 19}, {": ", 2}, {"error while loading shared libra"..., 36},
{": ", 2}, {"libjli.so", 9}, {": ", 2}, {"cannot open shared object file", 30}, {": ", 2},
{"No such file or directory", 25}, {"\n", 1}], 10jdk-14.0.1/bin/java: error while loading shared
libraries: libjli.so: cannot open shared object file: No such file or directory
) = 128
exit_group(127) = ?
显然,java 在我没有写入权限的地方搜索 libjli.so 共享库文件。
谷歌搜索后,我发现了许多类似的问题,但无法使用提供的任何提示,因为它们需要 root 访问权限。然而,我不相信没有 root 访问权限是问题的核心,因为在我的家庭 Linux 机器上解压相同的 tarball 可以毫无问题地运行相同的 java 二进制文件,也不使用 root 权限。因此,我假设还有一些其他先决条件,即服务器丢失。
在服务器上,运行uname -a
Yield Linux [...] 3.2.0-6-amd64 #1 SMP Debian 3.2.102-1 x86_64 GNU/Linux
,这对我来说并不奇怪。
当然,我非常感谢任何帮助,并很乐意提供更多信息。提前致谢。
答案1
首先,libjli.so
库应该在lib
目录中而不是bin
目录中。根据您的拥有方式,它应该位于以下两个位置之一
jdk-14.0.1/lib/
jdk-14.0.1/jli/
然后,您需要使用 PATH 和 JAVA_HOME 将它们的位置添加到您的环境中。将这些行添加到您的 .bashrc 并启动一个新的 shell 会话:
export PATH=/home/presencia/jdk-14.0.1/bin:$PATH
export LD_LIBRARY_PATH=/home/presencia/jdk-14.0.1/lib:$LD_LIBRARY_PATH
export JAVA_HOME=/home/presencia/jdk-14.0.1