由于ubuntu默认安装JAVA的openjdk版本没有装tools.jar,因此在某些情况下必须安装openjdk的完全版,如下命令即可完成:
sudo apt-get install openjdk-6-jdk
即可,一般默认安装目录为:/usr/lib/jvm/java-6-openjdk
如下命令,可以确定tools.jar已经存在于java-6-openjdk的lib目录下了
# ls /usr/lib/jvm/java-6-openjdk/lib/
ct.sym dt.jar ir.idl jconsole.jar jexec orb.idl sa-jdi.jar tools.jar
#
安装后,别忘了设置相关环境变量到相关配置文件中
1)
#cat /etc/environment
export JAVA_HOME=/usr/lib/jvm/java-6-openjdk
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:$JAVA_HOME/bin"
#
2)
#cat /etc/profile
#...最后添加如下
export JAVA_HOME=/usr/lib/jvm/java-6-openjdk
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
#
若操作系统中安装多个版本的java,可以采用如下命令来选择具体的java:
#sudo update-alternatives --config java
There are 2 choices for the alternative java (providing /usr/bin/java).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java 1061 auto mode
1 /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java 1061 manual mode
2 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1051 manual mode
Press enter to keep the current choice[*], or type selection number:
...
完毕。
sudo apt-get install openjdk-6-jdk
即可,一般默认安装目录为:/usr/lib/jvm/java-6-openjdk
如下命令,可以确定tools.jar已经存在于java-6-openjdk的lib目录下了
# ls /usr/lib/jvm/java-6-openjdk/lib/
ct.sym dt.jar ir.idl jconsole.jar jexec orb.idl sa-jdi.jar tools.jar
#
安装后,别忘了设置相关环境变量到相关配置文件中
1)
#cat /etc/environment
export JAVA_HOME=/usr/lib/jvm/java-6-openjdk
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:$JAVA_HOME/bin"
#
2)
#cat /etc/profile
#...最后添加如下
export JAVA_HOME=/usr/lib/jvm/java-6-openjdk
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
#
若操作系统中安装多个版本的java,可以采用如下命令来选择具体的java:
#sudo update-alternatives --config java
There are 2 choices for the alternative java (providing /usr/bin/java).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java 1061 auto mode
1 /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java 1061 manual mode
2 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1051 manual mode
Press enter to keep the current choice[*], or type selection number:
...
完毕。