问题
I'm trying to install JDK 1.7 in Ubuntu 11.04 but when I run the following command:
javac -version
I'm getting error below:
Error: could not find libjava.so
Error: Could not find Java SE Runtime Environment.
here is some information about my system configuration for you in order to solve my problem:
The end of /etc/profile:
JDK_HOME=/usr/local/java/jdk1.7.0_04
PATH=$PATH:$HOME/bin:$JDK_HOME/bin
JAVA_HOME=/usr/local/java/jre1.7.0_04
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
export JDK_HOME
export JAVA_HOME
export PATH
output of /etc/ld.conf.so.d/java.conf :
/usr/local/java/jre1.7.0_04/lib/i386/
/usr/local/java/jre1.7.0_04/lib/i386/jli/
output of $PATH:
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/sahar/bin:/usr/local/java/jdk1.7.0_04/bin:/home/sahar/bin:/usr/local/java/jre1.7.0_04/bin
Please help me to solve my problem.
回答1:
The problem is your JAVA_HOME is set twice in /etc/profile
, and the last one is the JRE. There are also many repeated entries inside your PATH. Simply remove the JRE and leave the JDK.
Also: this question would be better placed on Superuser.com
回答2:
Your JAVA_HOME and PATH are being written twice in your etc profile, and the second time is overwriting it with the jre JAVA_HOME so javac will not work. Take out the second JAVA_HOME and PATH assignment at the end of your etc/profile and reboot
来源:https://stackoverflow.com/questions/10759266/error-running-javac-in-ubuntu-11-04