思路:新建文件夹-解压-设置环境变量-测试环境变量
命令如下
新建文件夹-解压
sudo mkdir /usr/lib/jvm
sudo tar zxvf jdk-7u67-linux-x64.tar.gz -C /usr/lib/jvm
设置环境变量
sudo gedit /etc/profile
加入环境变量内容
#set java environment
export JAVA_HOME=/usr/lib/jvm/jdk1.7.0_67
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
设置默认的JDK
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.7.0_67/bin/java 300
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.7.0_67/bin/javac 300
测试
java -version
显示JDK版本则配置成功
root@ubuntu:/home/ubuntu/Public# java -version
java version "1.7.0_67"
Java(TM) SE Runtime Environment (build 1.7.0_67-b01)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)