CentOS installation JDK and environment configuration

Source: Internet
Author: User

1. CentOS By default, will install software such as OpenOffice, these software need Java support, the default installation of the JDK environment, if you need a specific Java environment, it is best to completely remove the default JDK;

2. View the default JDK command: java-version

3. If you remove the default reload of the new JDK, then the associated software will be deleted, so, first install the new re-unloading default.

4. Download jdk,http://www.oracle.com/technetwork/java/javase/downloads/jdk-7u4-downloads-1591156.html, I downloaded the jdk-7u4-linux-x64.rpm

5. Place the jdk-7u4-linux-x64.rpm in the/usr directory, command: MV JDK-7U4-LINUX-X64.RPM/USR

With the command chmod 777 jdk-7u4-linux-x64.rpm Modify the file permissions, double-click on it to automatically unzip the installation, after the installation is complete, in the/usr directory to generate a new Java folder

6. Setting Environment variables

VI Open File command: Vi/etc/profile

Move to the end of the file insert a blank line: Enter the letter O

Enter the following configuration information: (Note: The delimiter here is a colon is not a semicolon)

Java_home=/usr/java/jdk1.7.0_04

Path= $JAVA _home/bin: $PATH

Classpath=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar

Export Java_home

Export PATH

Export CLASSPATH

Press ESC to exit edit mode before saving exit Input: Wq! (colons are also entered)

At this point, the new JDK environment setting is complete.

7. Uninstalling the original JDK

Terminal input, view GCJ version number: Rpm-qa|grep JDK

Get results:

Jdk-1.7.0_04-fcs.x86_64

Java-1.6.0-openjdk-1.6.0.0-1.49.1.11.4.el6_3.x86_64

Terminal input, uninstall: Yum-y remove Java java-1.6.0-openjdk-1.6.0.0-1.49.1.11.4.el6_3.x86_64

Wait for the system to automatically uninstall, the final terminal display complete, uninstall completed

8. Allow system configuration to take effect immediately without rebooting the system

Terminal input Command: source/etc/profile (note: To be under root administrator)

Note: If the following error message appears

BASH:/usr/java/jdk1.7.0_04/lib/dt.jar: Insufficient permissions

BASH:/usr/java/jdk1.7.0_04/lib/tools.jar: Insufficient permissions

Workaround:

chmod a+w ....

CentOS installation JDK and environment configuration

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.