JDK versions (jdk1.7.0_21 and jdk1.7.0_55)
Installed and Configured like below.
jdk1.7.0_21
update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.7.0_21/bin/java" 1
update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.7.0_21/bin/javac" 1
update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jdk1.7.0_21/bin/javaws" 1
sudo chmod a+x /usr/bin/java
sudo chmod a+x /usr/bin/javac
sudo chmod a+x /usr/bin/javaws
sudo chown -R root:root /usr/lib/jvm/jdk1.7.0_21
jdk1.7.0_55
update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.7.0_55/bin/java" 1
update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.7.0_55/bin/javac" 1
update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jdk1.7.0_55/bin/javaws" 1
sudo chmod a+x /usr/bin/java
sudo chmod a+x /usr/bin/javac
sudo chmod a+x /usr/bin/javaws
sudo chown -R root:root /usr/lib/jvm/jdk1.7.0_55
and i am choosing/changing the default JDK by
update-alternatives --config java
update-alternatives --config javac
update-alternatives --config javaws
After this if i run java -version
while jdk1.7.0_55
is default, output's like below.
root@ssa-lpt:/usr/lib/jvm# java -version
java version "1.7.0_55"
Java(TM) SE Runtime Environment (build 1.7.0_55-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.55-b03, mixed mode)
but while jdk1.7.0_21
is default it gives an message like
java: error while loading shared libraries: libjli.so: cannot open
shared object file: No such file or directory
If i issue: locate libjli.so
/usr/lib/jvm/jdk1.7.0_55/jre/lib/amd64/jli/libjli.so
/usr/lib/jvm/jdk1.7.0_55/lib/amd64/jli/libjli.so
So it's clear that though i selected jdk1.7.0_21
but somehow it's still pointing to jdk1.7.0_55
Tried to rename the jdk1.7.0_55
but no luck.
Not sure how to fix this. Thanks in advance for your help 🙂
Solution:: My jdk1.7.0_21
was broken downloaded a fresh copy form oracle untar it in /usr/lib/jvm/
that was it.
Best Answer
There is too much reasons why you can see this error.
Could you please run all this commands one by one, and post output here:
file /usr/bin/java
type /usr/bin/java
echo $JAVA_HOME
echo $PATH
ls -ahl /usr/lib/jvm
Then - using
update-alternatives
choose jdk1.7.0_55 and run thisusing
update-alternatives
choose jdk1.7.0_21 and run thisthen again for jdk1.7.0_21 run this
UPDATE. Answer
For everyone who has same problem:
First of all, run sudo
ldconfig
. It is safe to runldconfig
at any timeAfter a long discussion we concluded that jdk1.7.0_21 is corrupted.
How we determine it:
jdk1.7.0_21
,sudo java -version
give error even if run as root.find /usr/lib/jvm -name "libjli.so"
, this command must show thatlibjli
is located in folder wherejdk1.7.0_21
installed. In our case it was not.In other cases:
Check that jdk belongs to
root:root
Check that
/usr/bin/java
is a symlink, not executable.Check
PATH
, java should not be in the PATH, if you are usingupdate-alternatives
.Also here is helpful links:
https://unix.stackexchange.com/questions/16656/problem-to-launch-java-at-debian-error-while-loading-shared-libraries-libjli
https://www.centos.org/forums/viewtopic.php?t=16398
https://superuser.com/questions/310371/problem-launch-java-on-debian-error-while-loading-shared-libraries-libjli-so