1、首先到oracle下载jdk-7u5-linux-x64.tar.gz 2、将jdk-7u5-linux-x64.tar.gz 解压到 /usr/lib/jvm/目录下面,这里如果没有jvm文件夹,则创建该文件夹,命令:
1 2 sudo mkdir jvm sudo tar zxvf ~/Downloads/jdk-7u5-linux-x64.tar.gz -C /usr/lib/jvm
3、设置环境变量,用gedit打开/etc/profile文件
在文件的最后面增加:
1 2 3 export JAVA_HOME=/usr/lib/jdk1.7.0_05export PATH=$JAVA_HOME /bin:$JAVA_HOME /jre/bin:$PATH export CLASSPATH=$CLASSPATH :.:$JAVA_HOME /lib:$JAVA_HOME /jre/lib
4、将系统默认的jdk修改过来
1 2 3 4 $ sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.7.0_05/bin/java 300 $ sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.7.0_05/bin/javac 300 $ sudo update-alternatives --config java $ sudo update-alternatives --config javac
5、检测,输入
1 2 3 4 java -version java version "1.7.0_05" Java(TM) SE Runtime Environment (build 1.7.0_05-b06) Java HotSpot(TM) 64-Bit Server VM (build 23.1-b03, mixed mode)