阅读更多
1.解压到一个目录
sudo tar zxvf jdk-7u45-linux-x64.tar.gz -C /disk1/jdk
2.设置环境变量
编辑 /etc/profile 文件追加
export JAVA_HOME=/disk1/jdk/jdk1.7.0_79
export CLASSPATH=".:$JAVA_HOME/lib:$CLASSPATH"
export PATH="$JAVA_HOME/bin:$PATH"
source /etc/profile
3.设置系统默认jdk
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.7.0_60/bin/java 300
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.7.0_60/bin/javac 300
sudo update-alternatives --install /usr/bin/jar jar /usr/lib/jvm/jdk1.7.0_60/bin/jar 300
sudo update-alternatives --install /usr/bin/javah javah /usr/lib/jvm/jdk1.7.0_60/bin/javah 300
sudo update-alternatives --install /usr/bin/javap javap /usr/lib/jvm/jdk1.7.0_60/bin/javap 300
sudo update-alternatives --config java