Install java jdk on CentOS and centosjavajdk on CentOS
In general, we need to uninstall the OPENJDK that comes with linux, and then install the sun jdk.
First, check whether the JDK that comes with Linux is installed.
Run the following command to view the installed JAVA version.
Linux code
- Java-version
Run the following command to view the JDK information.
Linux code
- Rpm-qa | grep java
As shown in.
Uninstall installed JAVA, as shown in.
The uninstall is completed, as shown in.
Detach another one, as shown in.
The uninstall is completed, as shown in.
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:
Linux code
- 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:
Linux code
- Cd/mnt/share
- Ls-
Copy the file to the/usr/java directory and enter the following command:
Linux code
- Cp *. gz/usr/java
Run the following command to view the/usr/java directory:
Linux code
- Cd/usr/java
- Ls-
As shown in.
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:
Linux code
- Mv jdk1.7.0 _ 13 jdk
As shown in.
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.
Linux code
- Rpm-ivh jdk-7u13-linux-x64.rpm
Finally, set the environment variables.
Enter the following command to enter the configuration file.
Linux code
- Vi/etc/profile
As shown in.
Go to the configuration file, as shown in. Delete the first line in the red box and change the configuration information of the following three lines.
Make environment variables take effect.
Execute the configuration file to make it take effect immediately. Enter the following command:
Linux code
- Source/etc/profile
Run the following command to verify whether the installation is successful:
Linux code
- Java-version
As shown in, the installation is successful!
Note: If the following error occurs when you run the java-version command: cannot execute binary file, the system version and JDK version do not match.
Enter "uname-a" on the linux terminal
Download the JDK corresponding to the system on the sun official website.
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.