Ubuntu 14.04 安裝 JDK 7.0

振宇要低調發表於2015-09-19

1、新建jvm資料夾-解壓

# mkdir /usr/lib/jvm
# tar zxvf jdk-7u79-linux-x64.gz -C /usr/lib/jvm 

 

2、設定環境變數,在/etc/profile檔案的最後面增加:

# vi /etc/profile
export JAVA_HOME=/usr/lib/jvm/jdk1.7.0_79
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH

 

3、將系統預設的jdk修改過來

# update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.7.0_79/bin/java 300
# update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.7.0_79/bin/javac 300
# update-alternatives --install /usr/bin/jar jar /usr/lib/jvm/jdk1.7.0_79/bin/jar 300
# update-alternatives --config java
# update-alternatives --config javac
#update-alternatives --config jar

 

4、測試

# java -version
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode) 

 

相關文章