Installing the JDK on Linux with Yum

Source: Internet
Author: User

Uninstall the JDK that comes with CentOS

1. Review the current JDK version and uninstall

[Email protected] opt]# rpm-qa|grepJava Java-1.6.0-openjdk-1.6.0.37-1.13.9.4. El5_11tzdata-java-2015g-1. El5//Uninstall[Email protected] opt]# rpm-e--allmatches--nodeps java-1.6.0-openjdk-1.6.0.37-1.13.9.4. El5_11[[email protected] opt]# rpm-E--allmatches--nodeps tzdata-java-2015g-1. el5

Installing the JDK

1. Find Java-related lists

[Email protected] jre-1.6.0-openjdk.x86_64]#Yum-y list java*Loaded plugins:fastestmirrorloading Mirror speeds from cached Hostfile*addons:mirrors.btte.net*base:centos.ustc.edu.cn*extras:centos.ustc.edu.cn*updates:centos.ustc.edu.cnInstalled Packagesjava-1.6.0-openjdk.x86_641:1.6.0.37-1.13.9.4. El5_11 installedavailable Packagesjava-1.4.2-gcj-compat.x86_641.4.2.0-40JPP. theBase Java-1.4.2-gcj-compat-devel.i3861.4.2.0-40JPP. theBase Java-1.4.2-gcj-compat-devel.x86_641.4.2.0-40JPP. theBase Java-1.4.2-gcj-compat-javadoc.x86_641.4.2.0-40JPP. theBase Java-1.4.2-gcj-compat-src.x86_641.4.2.0-40JPP. theBase Java-1.6.0-openjdk-demo.x86_641:1.6.0.37-1.13.9.4. El5_11 updates java-1.6.0-openjdk-devel.x86_641:1.6.0.37-1.13.9.4. El5_11 updates java-1.6.0-openjdk-javadoc.x86_641:1.6.0.37-1.13.9.4. El5_11 updates java-1.6.0-openjdk-src.x86_641:1.6.0.37-1.13.9.4. El5_11 updates java-1.7.0-openjdk.x86_641:1.7.0.91-2.6.2.1. El5_11 updates java-1.7.0-openjdk-demo.x86_641:1.7.0.91-2.6.2.1. El5_11 updates java-1.7.0-openjdk-devel.x86_641:1.7.0.91-2.6.2.1. El5_11 updates java-1.7.0-openjdk-javadoc.x86_641:1.7.0.91-2.6.2.1. El5_11 updates java-1.7.0-openjdk-src.x86_641:1.7.0.91-2.6.2.1. El5_11 Updates java_cup.x86_641:0.10-0. k.6jpp.1Base Java_cup-javadoc.x86_641:0.10-0. k.6jpp.1Base Java_cup-manual.x86_641:0.10-0. k.6jpp.1Base javacc.x86_644.0-3JPP.3Base JAVACC-demo.x86_644.0-3JPP.3Base JAVACC-manual.x86_644.0-3JPP.3Base

Or

[Email protected] jre-1.6.0-openjdk.x86_64]#Yumsearch jdkloaded plugins:fastestmirrorloading mirror speeds from cached Hostfile*addons:mirrors.btte.net*base:centos.ustc.edu.cn*extras:centos.ustc.edu.cn*updates:centos.ustc.edu.cn========================================================== MATCHED:JDK ========================================= =================Java-1.6.0-Openjdk.x86_64:OpenJDK Runtime Environmentjava-1.6.0-openjdk-Demo.x86_64:OpenJDK Demosjava-1.6.0-openjdk-Devel.x86_64:OpenJDK Development Environmentjava-1.6.0-openjdk-Javadoc.x86_64:OpenJDK API Documentationjava-1.6.0-openjdk-Src.x86_64:OpenJDK Source Bundlejava-1.7.0-Openjdk.x86_64:OpenJDK Runtime Environmentjava-1.7.0-openjdk-Demo.x86_64:OpenJDK Demosjava-1.7.0-openjdk-Devel.x86_64:OpenJDK Development Environmentjava-1.7.0-openjdk-Javadoc.x86_64:OpenJDK API Documentationjava-1.7.0-openjdk-Src.x86_64:OpenJDK Source Bundlegnu-crypto-sasl-jdk1.4. X86_64:gnu Crypto SASL Apijakarta-commons-beanutils.x86_64:Jakarta Commons beanutils packagejakarta-commons-Collections.x86_64:Jakarta Commons Collections Packagejakarta-commons-Launcher.x86_64:The Launcher Component is designed to being a cross platform Java application launcher.ldapjdk.x86_64: The Mozilla LDAP Java sdkldapjdk-javadoc.x86_64:javadoc forldapjdkmockobjects-alt-jdk1.4. x86_64:mockable API forJdk1.4mockobjects-jdk1.4. x86_64:mockobjects for 1.4Jdk

2. Installing the JDK

Yum Install java-1.6. 0- The MIs this ok [y/n]: Y

3. After the installation is complete, verify that

[Email protected] ~]# java-"1.6.0_37"1.13. 9) (rhel-1.13.  9.4. el5_11-23.25-b01, Mixed mode)

4. The path to the default installation via Yum is

/usr/lib/jvm

[Email protected] ~]# cd/usr/lib/Jvm[[email protected] jvm]# lltotal -drwxr-xr-x3Root root4096Jan A  -: onjava-1.6.0-openjdk-1.6.0.37. x86_64lrwxrwxrwx1Root root +Jan A  -: onJRE-/etc/alternatives/jrelrwxrwxrwx1Root root -Jan A  -: onjre-1.6.0/etc/alternatives/jre_1.6.0lrwxrwxrwx1Root root -Jan A  -: onjre-1.6.0-openjdk.x86_64-java-1.6.0-openjdk-1.6.0.37. x86_64/jrelrwxrwxrwx1Root root inJan A  -: onJRE-OPENJDK-/ETC/ALTERNATIVES/JRE_OPENJDK

If more than one JDK is installed on the machine, the Java command can point to only one version of the JDK, in order to make it easy to modify the JDK version in the global

The /etc/alternatives directory below will have a Java link to the Bin/java command that defaults to the version of the JDK that needs to be executed

[[email protected] jvm]# cd/etc/2041:01 Java-/usr/lib/jvm/jre-1.6. 0-openjdk.x86_64/bin/java

and /etc/alternatives/java will be soft connected to /usr/bin/java

5. Add the JDK installation path to the Java_home

Method One:

VI /etc/profile

At the end of the document, add:

#set java environmentjava_home=/usr/lib/jvm/jre-1.6. 0-openjdk.x86_64path= $PATH: $JAVA _home/Binclasspath=.: $JAVA _home/lib/dt.jar: $JAVA _ home/lib/tools.jarexport java_home CLASSPATH PATH

Modify/etc/profile to take effect

[Email protected] alternatives]#. /etc/profile

Attention . Then there should be a space

Method Two:

Or install the form of the Java command above to make it easier to modify

[Email protected] jvm]# cd/etc/Ln -s/usr/lib/jvm/jre-1.6. 0-openjdk.x86_64/java_home

Create a /etc/alternatives/java_home soft connection that points the connection to the root of the current JDK

Then add the path to the connection.

#set java environmentjava_home=/etc/alternatives/java_homepath= $PATH: $JAVA _home/  Binclasspath=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jarexport java_home CLASSPATH PATH
[Email protected] alternatives]# Export | grep  -X java_home="/etc/alternatives/java_home"

Focus on technical details and improve your self-ability.

--------End------------

Installing the JDK on Linux with Yum

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.