1. Download jdk-7-linux-x64.rpm (http://www.oracle.com/technetwork/java/javase/downloads/java-se-jdk-7-download-432154.html)
2. Switch Su to root
3./usr/Java/jdk1.7.0
Rpm-IVH jdk-7-linux-x64.rpm, default installation path:/usr/Java/jdk1.7.0
4. VI/etc/profile
5. append at the end of profile:
[Plain]
View plaincopyprint?
- Export java_home =/usr/Java/jdk1.7.0
- Export classpath =.: $ java_home/JRE/lib/RT. jar: $ java_home/lib/dt. jar: $ java_home/lib/tools. Jar
- Export Path = $ path: $ java_home/bin
Export java_home =/usr/Java/jdk1.7.0 <br/> export classpath =.: $ java_home/JRE/lib/RT. jar: $ java_home/lib/DT. jar: $ java_home/lib/tools. jar <br/> export Path = $ path: $ java_home/bin
Note that the link in the middle is a colon, not a semicolon!
Path = $ path: $ java_home/bin is the definition variable
Export Path = $ path: $ java_home/bin must be export to take effect
When using export, remember to include the original path with Path = $ path: $ home/bin. Otherwise, the system path will be overwritten.
6. Source/etc/profile
7. Install update-Alternatives
Update-alternatives -- install/usr/bin/Java/usr/Java/jdk1.7.0/bin/Java 60
Configure JDK
Update-alternatives -- config Java
Then
[Plain]
View plaincopyprint?
- There are two programs that provide "Java ".
- Select command
- -----------------------------------------------
- * + 1/usr/lib/JVM/jre-1.6.0-openjdk/bin/Java
- 2/usr/Java/jdk1.7.0/bin/Java
- Press enter to save the current selection [+], or type the selection number: 2
There are two programs that provide "Java ". </P> <p> SELECT command <br/> --------------------------------------------- <br/> * + 1/usr/lib/JVM/jre-1.6.0-openjdk/bin/Java <br/> 2/usr /Java/jdk1.7.0/bin/Java </P> <p> press enter to save the current selection [+]. or enter the selected number: 2.
Press enter.
Java-version output
[Plain]
View plaincopyprint?
- Java version "1.7.0"
- Java (TM) se Runtime Environment (build 1.7.0-b147)
- Java hotspot (TM) 64-bit server VM (build 21.0-b17, mixed mode)