1. Download jdk-7u45-linux-x64.tar.gz
URL: http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
2, Unzip the JDK
Go to the download directory of the JDK
- sudo tar zxvf jdk-7u45-linux-x64.tar.gz -C /usr/lib/jvm
3, set environment variables (global)
- sudo gedit /etc/profile
Open the profile file and enter
- export JAVA_HOME=/usr/lib/jvm/jdk1.7.0_65
- export CLASSPATH=".:$JAVA_HOME/lib:$CLASSPATH"
- export PATH="$JAVA_HOME/bin:$PATH"
4, set the system default JDK
- sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.7.0_65/bin/java 300
- sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.7.0_5/bin/javac 300
- sudo update-alternatives --config java
5, Verify JDK
input the command
- java -version
Seeing the JDK information means success.