1. Download the corresponding version of JDK, I am using the JDK7-linux32 bit version: jdk-7u7-linux-i586.tar.gz. I put the file under/home/linuxidc/Downloads. (Linuxidc is my username :)) 2. Unzip the package. Cd/home/linuxidc/Downloads & nbs
1. Download the corresponding JDK version, I am using a 32-bit JDK7-linux version: jdk-7u7-linux-i586.tar.gz. I put the file under/home/linuxidc/Downloads. (Linuxidc is my User Name :))
2. decompress the package.
Cd/home/linuxidc/Downloads // enter the directory where the jdk file is located
Tar-zxvf jdk-7u7-linux-i586.tar.gz // After executing this command, we will find that there is a folder under the change path: jdk1.7.0 _ 07, This is the file we obtained after decompression.
Sudo mv jdk1.7.0 _ 07/opt // move the entire jdk1.7.0 _ 07 folder together to the/opt/directory, because generally installed files like to put under/opt, this is my preference.
3. Modify environment variables:
Sudo gedit/etc/environment // here I modified this file, but you can also modify it ~ /. Bashrc or ~ /. Profile. I will not describe these differences here. If you are interested, google them ~
Add the following at the end of the first line:
$ {JAVA_HOME}/bin
Add
Export JAVA_HOME =/opt/jdk1.7.0 _ 07
Export JRE_HOME =$ {JAVA_HOME}/jre
Export CLASSPATH =. :$ {JAVA_HOME}/lib :$ {JRE_HOME}/lib
Before modification:
PATH = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"
After modification:
PATH = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games: $ {JAVA_HOME}/bin"
Export JAVA_HOME =/opt/jdk1.7.0 _ 07
Export JRE_HOME =$ {JAVA_HOME}/jre
Export CLASSPATH =. :$ {JAVA_HOME}/lib :$ {JRE_HOME}/lib
Then execute source ~ /. Bashrc
4. Change the system's default jdk to the jdk we just installed, because there may be other installed jdk in the system.
Sudo update-alternatives -- install/usr/bin/java/opt/jdk1.7.0 _ 07/bin/java 300
Sudo update-alternatives -- install/usr/bin/javac/opt/jdk1.7.0 _ 07/bin/javac 300
Sudo update-alternatives -- install/usr/bin/javah/opt/jdk1.7.0 _ 07/bin/javah 300
Sudo update-alternatives -- install/usr/bin/jar/opt/JDK 1.7.0 _ 07/bin/jar 300
5. It's time to test our installation results:
Java-version
Linuxidc @ linuxidc :~ $ Java-version
Java version "1.7.0 _ 07"
Java (TM) SE Runtime Environment (build 1.7.0 _ 07-b10)
Java HotSpot (TM) Server VM (build 23.3-b01, mixed mode)
So far, jdk installation is over. I hope you will be able to succeed!