In general, we need to uninstall the OPENJDK that comes with linux, and then install the sun jdk.
First, uninstall the built-in java
Check whether the JDK that comes with Linux is installed.
Run the following command to view the installed Java version.
Java-version
Run the following command to view the JDK information.
Rpm-qa | grep java
As shown in the following figure.
Uninstall installed JAVA, as shown in the following figure.
The uninstall is completed, as shown in the following figure.
Uninstall the other one, as shown in the following figure.
The uninstall is completed, as shown in the following figure.
Step 2: install SUN's JDK.
Official website: http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
Create a java directory under/usr to install the java program in this directory. Enter the following command:
Mkdir/usr/java
Copy the downloaded installation file to the share folder of the original system and run the following command to view the file:
Cd/mnt/share
Ls-
Copy the file to the/usr/java directory and enter the following command:
Cp *. gz/usr/java
Run the following command to view the/usr/java Directory:
Cd/usr/java
Ls-
Decompress the file and enter the following command: Linux code
Tar-xzvf jdk-7u13-linux-x64.gz
After decompression, a new directory jdk1.7.0 _ 13 will be generated under the/usr/java directory, which stores the decompressed files. For later setup convenience, we changed the directory jdk1.7.0 _ 13 to jdk. Enter the following command:
Mv jdk1.7.0 _ 13 jdk
Alternatively, if the downloaded file is in rpm format, replace the tar command with the following command to install it. The other steps remain unchanged.
Rpm-ivh jdk-7u13-linux-x64.rpm
Finally, set the environment variables. Enter the following command to enter the configuration file, or open the configuration file in other ways.
Vi/etc/profile
Go to the configuration file, as shown in the following figure, and delete the following 1st rows, for the following 2-4 lines of configuration information.
Export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL
Export JAVA_HOME =/usr/local/jdk1.7.0 _ 79
Export PATH = $ JAVA_HOME/bin: $ PATH
Export CLASSPATH =.: $ JAVA_HOME/lib/dt. jar: $ JAVA_HOME/lib/tools. jar
Make environment variables take effect. Execute the configuration file to make it take effect immediately. Enter the following command:
Source/etc/profile
Run the following command to verify whether the installation is successful:
Java-version