2

I'm trying to launch Java:

$ java -version
java: error while loading shared libraries: libjli.so: cannot open shared object file: No such file or directory

$ ldd /usr/lib/jvm/java-6-openjdk/jre/bin/java
        linux-gate.so.1 =>  (0xb779f000)
        libz.so.1 => /usr/lib/libz.so.1 (0xb7780000)
        libpthread.so.0 => /lib/i686/cmov/libpthread.so.0 (0xb7767000)
        libjli.so => /usr/lib/jvm/java-6-openjdk/jre/bin/../lib/i386/jli/libjli.so (0xb7762000)
        libdl.so.2 => /lib/i686/cmov/libdl.so.2 (0xb775e000)
        libc.so.6 => /lib/i686/cmov/libc.so.6 (0xb7603000)
        /lib/ld-linux.so.2 (0xb77a0000
$ ls /usr/lib/jvm/java-6-openjdk/jre/bin/../lib/i386/jli/
libjli.so

However Java does work under root:

$ sudo java -version
java version "1.6.0_18"
OpenJDK Runtime Environment (IcedTea6 1.8.7) (6b18-1.8.7-2~lenny1)
OpenJDK Client VM (build 14.0-b16, mixed mode, sharing)

How can I launch Java as a regular user without errors?

6
  • here's an attempt at an answer
    – tshepang
    Commented Jul 14, 2011 at 9:20
  • For Linux-related questions, you will normally get a better/faster response from U&L. Just my experience.
    – tshepang
    Commented Jul 14, 2011 at 9:24
  • I regularly had problems with the OpenJDK version of Java... Maybe you should try with the non-free Java? Do a aptitude search sun-java6 (you need to have the non-free repositories enabled in your sources.list).
    – mp04
    Commented Jul 14, 2011 at 12:18
  • Could you give details on your linux distribution & method of installing java? This looks like it could be a PATH issue. I'm guessing you also need to run through update-alternatives.
    – Pricey
    Commented Jul 14, 2011 at 13:47
  • I'm tried update-alternatives. I't does not give effect.
    – aetaur
    Commented Jul 14, 2011 at 16:15

4 Answers 4

1

Pay attention how the links are configured. I found a server where a mistake had happen and /etc/bin/java was replaced with a binary. That made the library not found error to appear. I relinked /usr/bin/java to /etc/alternatives/java, and all works again.

# namei -mx /usr/bin/java
f: /usr/bin/java
 drwxr-xr-x /
 drwxr-xr-x usr
 drwxr-xr-x bin
 lrwxrwxrwx java -> /etc/alternatives/java
   drwxr-xr-x /
   drwxr-xr-x etc
   drwxr-xr-x alternatives
   lrwxrwxrwx java -> /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java
     drwxr-xr-x /
     drwxr-xr-x usr
     drwxr-xr-x lib
     drwxr-xr-x jvm
     lrwxrwxrwx jre-1.6.0-openjdk.x86_64 -> java-1.6.0-openjdk-1.6.0.0.x86_64/jre
       drwxr-xr-x java-1.6.0-openjdk-1.6.0.0.x86_64
       drwxr-xr-x jre
     drwxr-xr-x bin
     -rwxr-xr-x java

My hunch is that OpenJDK does some sort of path canonisation when it looks for libs.

1

Perhaps you've got a single instance from Ubuntu with no elevated privs, but it still can't find the lib as in this report.

Try

ln -s /usr/lib/jvm /lib
1

That problem happened to me when you run java in a chroot-jail.

If you check with chrpath out from the chroot you will see something like this:

chrpath /opt/test/demo/opt/test/jdk/bin/java
/opt/test/demo/opt/test/jdk/bin/java: RPATH=$ORIGIN/../lib/amd64/jli:$ORIGIN/../jre/lib/amd64/jli

ELF for security not evaluate $ORIGIN witch isn't an environment var so you have to set some environment variable before run the java:

export JAVA_HOME=/opt/test/jdk
export LD_LIBRARY_PATH=$JAVA_HOME/lib/amd64/jli:$JAVA_HOME/jre/lib/amd64/jli

or

LD_ORIGIN_PATH=/opt/test/jdk/bin /opt/test/jdk/bin/java
1

I know this is a very old question, but I just ran in to the same problem and think the following link may help:

https://unix.stackexchange.com/questions/87978/how-to-get-oracle-java-7-to-work-with-setcap-cap-net-bind-serviceep

The problem may occur if you grant posix capabilities to the java executable. In that case, ld.so will refuse to link libjli.so if run java as a non-root user. The detailed causes and solution can be found in the link above, but to be short, executing the following lines of command as root should solve the problem:

echo /opt/java/jdk1.7.0_71/lib/amd64/jli >> /etc/ld.so.conf.d/java.conf
rm /etc/ld.so.cache
ldconfig -v|grep jli

Remember to replace /opt/java/jdk1.7.0_71 with your actual java home path, and use /lib/i386/jli if you're on 32-bit machine. If the last command returns something like

libjli.so -> libjli.so

, you should be good to go. If the ld.so cache is not refreshed correctly, you may need to restart your machine in some cases.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .