Install java jdk on CentOS and centosjavajdk on CentOS

Source: Internet
Author: User

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
  1. Java-version

 

Run the following command to view the JDK information.

Linux code
  1. 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
  1. 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
  1. Cd/mnt/share
  2. Ls-

 

Copy the file to the/usr/java directory and enter the following command:

Linux code
  1. Cp *. gz/usr/java

 

Run the following command to view the/usr/java directory:

Linux code
  1. Cd/usr/java
  2. Ls-

 

As shown in.


 

Decompress the file and enter the following command:

Linux code
  1. 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
  1. 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
  1. Rpm-ivh jdk-7u13-linux-x64.rpm

Finally, set the environment variables.

Enter the following command to enter the configuration file.

Linux code
  1. 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
  1. Source/etc/profile

 

Run the following command to verify whether the installation is successful:

Linux code
  1. 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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.