Install jdk correctly in centos and jdk in centos

Source: Internet
Author: User

Install jdk correctly in centos and jdk in centos

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:

[Root @ luozhonghua usr] # rpm-qa | grep jdk
Jdk-1.7.0_02-fcs.i586
[Root @ luozhonghua 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

[Root @ luozhonghua javacode] # javac test. java
[Root @ luozhonghua javacode] # java test
Hello!








In CentOS, I installed JDK 17 and set the environment to change. echo can display my settings, but I still use java-version.

It is recommended to delete the previous JDK and export your Jdk environment variables in/etc/profile. However, my CentOS does not delete the previous jdk. The new version is available.

Install jdk-bash on CentOS: java: command not found

It may be a JDK installation error. You can uninstall it and reinstall it once. Javac, check whether

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.