First of all, the default JDK means that after we install the CentOS system comes with the JDK, download and install the JDK itself only need to download, unzip, then the steps are consistent with this article
1. View the location of our default JDK
Instructions:
[HTML]View PlainCopy
- which Java
Let's go check it out. Discovery is a hyperlink, continue tracking
hyperlinks, Instructions:
[HTML]View PlainCopy
- Ls-lrt
Keep tracking.
There's a JDK, let's go check it out.
We found the initial jdk1.7 position (i.e. the system current JDK), and we needed the location of the jdk1.6 version, that is, jre-1.6.0-openjdk.x86_64, recorded
/usr/lib/jvm/jre-1.6.0-openjdk.x86_64
2. Modifying environment variables
Instructions:
[HTML]View PlainCopy
- Vim/etc/profile
In this position I append:
[HTML]View PlainCopy
- Export java_home=/usr/lib/jvm/jre-1.6.0-openjdk.x86_64
- Export path= $PATH: $JAVA _home/bin
- Export classpath=.: $JAVA _home/lib/tools.jar: $JAVA _home/lib/dt.jar
Press ESC to enter: Wq Save and exit
Make environment variables effective
[HTML]View PlainCopy
- Source/etc/profile
Update JDK
[HTML]View PlainCopy
- Update-alternatives--install/usr/bin/java Java/usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java 300
- Update-alternatives--install/usr/bin/javac Javac/usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/javac 300
- Update-alternatives--install/usr/bin/jar Jar/usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/jar 300
- Update-alternatives--config Java
Select the same name, enter the subscript
Test it.
directive: Java-version
found that the JDK version has been modified
Linux CentOS 6.5 uses your own JDK to modify environment variables