1. Uninstall jdk1.4
Jdk1.4 is installed in Redhat Enterprise 5. Before jdk1.6 is installed, uninstall jdk1.4:
1. First, check the built-in JDK version:
[Root @ linux ~] # Java-version
Java version "1.4.2"
Gij (GNU libgcj) version 4.1.2 20080704 (Red Hat 4.1.2-48)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
Warranty; not even for MERCHANTABILITY or fitness for a particle PURPOSE.
2. Determine the JDK version and uninstall it:
[Root @ linux ~] # Rpm-qa | grep jdk
[Root @ linux ~] # Rpm-qa | grep gcj
Libgcj-4.1.2-42.el5
Java-1.4.2-gcj-compat-1.4.2.0-40jpp.115
First confirm the specific jdk version number, and then use the rpm-e -- nodeps command to delete the content found above:
# Rpm-e -- nodeps java-1.4.2-gcj-compat-1.4.2.0-40jpp.115
Complete!
3. Check the JDK version again and uninstall it successfully:
[Root @ linux ~] # Java-version
-Bash:./usr/bin/java: No such file or directory
Ii. jdk1.6 Installation
Start to manually install the latest jdk1.6 version, jdk-6u33-linux-i586.bin
1. Assign permissions to the jdk-6u33-linux-i586.bin, specifically here to give it executable permissions
[Root @ linux ~] # Chmod + x jdk-6u33-linux-i586.bin
2. then unzip:./jdk-6u33-linux-i586.bin
[Root @ linux ~] #./Jdk-6u33-linux-i586.bin
3. After the execution, there will be a bunch of agreement or something, all the way more. Then there is a confirm installation, enter yes, and then press Enter. Start decompression. Until
Java (TM) SE Development Kit 6 successfully installed.
.........
Press Enter to continue .....
Done.
4. The decompressed file is as follows:
[Root @ linux ~] # Ls
Jdk1.6.0 _ 33 jdk-6u33-linux-i586.bin
5. Generally, the installation files are stored in usr/local and copied:
[Root @ linux ~] # Mv jdk1.6.0 _ 33/usr/local
[Root @ linux ~] # Cd/usr/local
[Root @ linux local] # ls
Bin etc games include jdk1.6.0 _ 33 lib libexec sbin share src
6. jdk has been successfully moved to/usr/local, and then the last step is to set the environment variable.
7. There are two types of settings. One is to temporarily take effect through the export setting. The setting will be lost after the restart, and the other is to write the settings to the/etc/profile file, which will take effect all the time. Therefore, the best setting is to write to the file. Run the following command:
[Root @ linux local] # vi/etc/profile
8. Open the profile file, enter I to enter the insert mode, and add the following content at the end of the file.
Export JAVA_HOME = "/usr/local/jdk1.6.0 _ 33"
Export CLASS_PATH = "$ JAVA_HOME/lib: $ JAVA_HOME/jre/lib"
Export PATH = ".: $ PATH: $ JAVA_HOME/bin"
Then run esc, enter wq, save and exit.
9. Then you need to set the settings to make the changes take effect:
[Root @ linux local] # source/etc/profile
Of course, if you like to restart, you can also reboot.
10. view the current jdk version.
[Root @ linux local] # java-versionjava version "1.6.0 _ 33"
Java (TM) SE Runtime Environment (build 1.6.0 _ 33-b03)
Java HotSpot (TM) Client VM (build between 8-b03, mixed mode, sharing)
Installation complete!