8

I tried installing openjdk6, openjdk7, oracle8... But always the same error when I want to execute java, for example with java -version:

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

I tried with symbolic links trying to get to recognize libjli.so but it didn't work

After uninstalling all versions, following the steps shown here How to completely uninstall Java? , and installing again, can't make the error disappear. Even if I uninstall it all again, if I write in terminal java -version it stills throw me the same error.

I'm doing all of this with user sudo.

Thank you

EDIT: Using Ubuntu 14.04 LTS Server

EDIT 2: Installing Openjdk7, Oracle7 and Oracle8, using update-alternatives --config java tells me that (in Spanish, but I'll try to translate, 3 lines of information)

"there is only one alternative in the group of java links in /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java Nothing to configure."

"update-alternatives: warning: forcing reinstallation of alternative /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java because the Java links' group is broken"

"update-alternatives: warning: /usr/bin/java will not be substituted by a link"

Geiser
  • 282
  • 1
  • 2
  • 14

6 Answers6

8

I meet this issue in a chroot environment, and fix it by this action

mount --bind /dev /myroot/dev
mount --bind /proc /myroot/proc
GKFX
  • 362
Simon
  • 81
  • I only needed to mount /proc into my small chroot for this particular issue. /dev and /dev/pts also helpful. – fuzzyTew Nov 17 '20 at 18:38
5

I encountered this problem when I made a hard-link to the java executable and tried to execute it. I'm presuming it was looking for its libraries using a relative path to the executable binary.

I tried both of these options, and each worked for me:

  • Putting the hard-link in the same directory as the java binary and running it from there (/usr/lib/jvm/openjre-8/bin in my case)
  • Creating and using a symbolic link instead of a hard link (ie. with ln -s $(which java) /usr/bin/${my_binary_name})
maniac
  • 51
5

Finally found the solution:

rm /usr/bin/java
update-alternatives --config java

Now it works by removing that binary, it was causing problems. Doesn't know if update-alternatives had any effect, but the last warning didn't show.

Geiser
  • 282
  • 1
  • 2
  • 14
0

what working with me is not using the java under

$JAVA_HOME/bin/

but the usage of the java under

$JAVA_HOME/jre/bin

which already has a link to the missing lib .

This happened for me when using oracle jdk 8 v 191 along with eclipse

and it act the same for openjdk you may use

/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
mebada
  • 171
  • 1
  • 3
0

I encountered the same question on CentOS when I installed the jdk1.8 .

I solved it by:

first, you should give the file execute permission,then install and config it.

chmod a+x jdk-8u151-linux-x64.tar.gz

actually,the libji.so file is in the directory

jdk1.8.0_151/jre/lib/amd64/jli/libjli.so
-1

I had the same problem upon launching a fresh install of the Arduino IDE
(even after running also the script arduino-linux-setup.sh).

Everything was installed under $HOME/Downloads/arduino-1.8.12/.

In this folder there was a java/bin/java executable, apparently looking for a ../lib/amd64/jli/libjli.so, so I tried to give it one as a soft symlink to /usr/lib/jvm/default-java/lib/jli/libjli.so, and it solved the problem.

I came to this solution on trying to reproduce under the install folder some of the standard Java folder structure.

  • “[mkdir … &] cd ~/Downloads/arduino-1.8.12/java/lib/amd64/jli”, then “ln -s /usr/lib/jvm/default-java/lib/jli/libjli.so”. – PedroJVM Feb 26 '20 at 20:13