1. first download JDK from the JDK official website. it has been updated to JDK 7. select JavaPlatform (JDK) 7 ). Check your acceptlicenseagreement, then download the second jdk-7-linux-i586.tar.gz 2. after the download is complete, you need to download the file on your device...
1. first download JDK from the JDK official website. it has been updated to JDK 7. select the first JDK 7 ).
Check the above Accept License Agreement option, then download the second jdk-7-linux-i586.tar.gz
2. after the download is complete, you need to create a folder on your computer to install jdk
Take my example:
Jdk installed in/usr/java
Terminal: $ sudo mkdir/usr/java
Because the folder is created in usr, normal users do not have the permission, so sudo certainly you can su, but we do not recommend su
3. decompress the downloaded compressed file to your installation directory.
Download to/home/ghz/download by default.
Terminal: sudo tar zxvf/home/ghz/download-C/usr/java
OK. At this time, jdk has been decompressed from download to/usr/java.
4. rename
Go to/usr/java
Terminal: cd/usr/java
Terminal: sudo mv jdk1.7.0 java-7-sun
5. write and modify the configuration file:
Vim ~ /. Bashrc
Then add the following code:
Export JAVA_HOME =/usr/lib/jvm/java-7-sun
Export JRE_HOME =$ {JAVA_HOME}/jre
Export CLASSPATH =. :$ {JAVA_HOME}/lib :$ {JRE_HOME}/lib
Export PATH =$ {JAVA_HOME}/bin: $ PATH
Then: x or: wq is saved and exited.
Make it effective immediately: source ~ /. Bashrc
6. enter sudo update-alternatives -- install/usr/bin/java/usr/java-7-sun/bin/java 300 on the terminal.
Enter sudo update-alternatives -- install/usr/bin/javac/usr/java-7-sun/bin/javac 300 on the terminal
Enter sudo update-alternatives -- config java on the terminal
Select the jdk you just installed as the default jdk.
7. You can write a java file.
Compile it with javac and run it with java
8. jdk is successfully installed.
From: Lingfeng