2

I would like to run java on a simple web hosting server to which I have ssh access but no root privilege. I have downloaded and unpacked the jdk linux/x64 tarball but running the java binary then yields

jdk-14.0.1/bin/java: error while loading shared libraries: libjli.so:
cannot open shared object file: No such file or directory

The file libjli.so is located in the jdk-14.0.1/lib subdirectory but the java binary doesn't seem to be able to find it.

Running strace jdk-14.0.1/bin/java yields:

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)                         = ?

Apparently, java searches for the libjli.so shared library file in places to which I do not have writing access.

Googling around, I have found a number of similar questions but couldn't use any of the hints provided since they require root access. However, I am not convinced that not having root access is the core of the problem because unpacking the same tarball on my home linux box allows to run the same java binary with no problems, not using root privileges either. I therefore assume that there is some other precondition that the server is missing.

On the server, running uname -a yields Linux [...] 3.2.0-6-amd64 #1 SMP Debian 3.2.102-1 x86_64 GNU/Linux, which doesn't seem strange to me.

Of course, I would highly appreciate any help and will happily provide further information. Thanks in advance.

1 Answer 1

4

Firstly, libjli.so library should be in the lib directory and not the bin directory. According to the way that you have it, it should be in one of the following two locations

jdk-14.0.1/lib/
jdk-14.0.1/jli/

You then need to add their location to your environment with PATH and JAVA_HOME. Add these lines to your .bashrc and start a new shell session:

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
3
  • You are perfectly right, the libjli is in the lib directory. I just corrected my question accordingly. However, adding the bin (or the lib) directory to the PATH environment variable as well as setting JAVA_HOME did not help here. I can now call java without providing the path explicitly but still get the libjli not found error.
    – presencia
    Apr 19, 2020 at 21:57
  • @presencia Add the LD_LIBRARY_PATH line in my update to ~/.bashrc and start a new shell session. Apr 19, 2020 at 22:12
  • 2
    Adding LD_LIBRARY_PATH solves it. Thank You!
    – presencia
    Apr 20, 2020 at 8:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.