Install JDK correctly on centos

Source: Internet
Author: User

1 first, find the default Java installation in centos

Whereis Java
Which Java (Java execution path)
Echo $ java_home

Echo $ path

2> View and uninstall:

Check if there is any Java command: rpm-Qa | grep Java

Delete if any: PM-e -- nodeps java-1.4.2-gcj-compat-1.4.2.0-40jpp.115
Rpm-e -- nodeps java-1.6.0-openjdk-1.6.0.0-1.7.b09.el5

Check whether JDK rpm-Qa | grep JDK is available.

Delete if any:

[[Email protected] USR] # rpm-Qa | grep JDK
Jdk-1.7.0_02-fcs.i586
[[Email protected] USR] # rpm-e -- nodeps jdk-1.7.0_02-fcs.i586

Check if there is any rpm-Qa | grep gcj


3 install

Rpm-IVH jdk-7u2-linux-i586.rpm

After the installation, a Java folder is automatically decompressed under/usr/, which has a jdk1.7.0 _ 02 folder.


4 Configuration

Add VI/etc/profile


Export java_home =/usr/Java/jdk1.7.0 _ 02
Export classpath =.: $ java_home/JRE/lib/RT. jar: $ java_home/lib/dt. jar: $ java_home/lib/tools. Jar
Export Path = $ path: $ java_home/bin


5 Test

[[Email protected] javacode] # javac test. Java
[[Email protected] javacode] # Java Test
Hello!







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.