Under normal circumstances, we will have to uninstall the OpenJDK Linux comes with. Then install Sun's JDK.
First check to see if the Linux-brought JDK is installed.
Enter for example the following command to view the Java version number information that has been installed.
Linux Code
- Java-version
Enter for example the following command. View the information for the JDK.
Linux Code
- Rpm-qa|grep Java
For example, as seen in the.
Uninstall the Java that you have installed, for example, as seen in.
Uninstall complete. For example, as seen in the.
Uninstall the other one, for example, as seen.
The uninstallation is complete, for example, as seen.
The second step is to install the sun's JDK.
Official website: http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
Create a Java folder under/usr. In case the Java program is installed in this folder. Enter for example the following command:
Linux Code
- Mkdir/usr/java
Copy the downloaded installation file to the original system's shared directory share, and view the file by command:
Linux Code
- Cd/mnt/share
- Ls-a
Copy the files to the/usr/java folder. Enter for example the following command:
Linux Code
- CP *.gz/usr/java
View the/usr/java folder. Enter for example the following command:
Linux Code
- Cd/usr/java
- Ls-a
For example, as seen in the.
Unzip the file, enter for example the following command:
Linux Code
- TAR-XZVF jdk-7u13-linux-x64.gz
After decompression, in the/usr/java folder will be generated a new folder Jdk1.7.0_13, the folder is stored in the extracted files.
For ease of Setup later, we renamed the folder Jdk1.7.0_13 to JDK. Enter for example the following command:
Linux Code
- MV Jdk1. 7. 0_13 JDK
For example, as seen in the.
Or, suppose the file you downloaded is in RPM format. Use the tar command above. Replace with the following command to install. The other steps do not change.
Linux Code
- RPM-IVH jdk-7u13-linux-x64.rpm
Finally, the environment variable is set.
Enter a configuration file such as the following command.
Linux Code
- Vi/etc/profile
For example, as seen in the.
Enter the configuration file. For example, as seen in the. Remove the first row in the red box and change to the following three lines of configuration information.
Let the environment variable take effect.
Run the configuration file so that it takes effect immediately and enter such as the following command:
Linux Code
- Source/etc/profile
Verify that the installation is successful, such as the following command:
Linux Code
- Java-version
For example, as seen in the. Indicates a successful installation!
Note: Assuming that the Execute java-version command appears:cannot execute binary file, the system version number and JDK version number are not met.
in Linux terminal input; Uname-a
Download the appropriate JDK for the system on Sun's website.
CentOS installation Java JDK