Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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/

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?

share|improve this question
here's an attempt at an answer –  Tshepang Jul 14 '11 at 9:20
For Linux-related questions, you will normally get a better/faster response from U&L. Just my experience. –  Tshepang Jul 14 '11 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). –  nodiscc Jul 14 '11 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. –  PriceChild Jul 14 '11 at 13:47
I'm tried update-alternatives. I't does not give effect. –  aetaur Jul 14 '11 at 16:15

3 Answers 3

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-
       drwxr-xr-x java-1.6.0-openjdk-
       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.

share|improve this answer

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.


ln -s /usr/lib/jvm /lib
share|improve this answer

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


LD_ORIGIN_PATH=/opt/test/jdk/bin /opt/test/jdk/bin/java
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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