Installing JDK under Linux

Source: Internet
Author: User
Tags curl mixed

Method One: Manually install the JDK installation package, configure the environment variables

1. Create a Java directory under the/usr/directory

[Email protected] ~]# mkdir/usr/~]# Cd/usr/java

2. Download and unzip the installation package

[[email protected] java]# Curl-o http://[[email protected] java]# TAR-ZXVF jdk-7u79-linux-x64.tar.gz

3. Setting Environment variables

[Email protected] java]# Vi/etc/profile

Enter VI edit mode, add the following code:

#Set  java environmentjava_home=/usr/java/jdk1. 7 . 0_79jre_home=/usr/java/jdk1. 7. 0_79/Jreclass_path=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar: $JRE _home/LibPATH = $PATH: $JAVA _home/bin: $JRE _home/binexport java_home jre_home class_path PATH

Let the changes take effect:

[Email protected] java]# Source/etc/profile

4. Verification

[Email protected] java]# java-"1.7.0_79"1.7. 0_79-   - 24.79-b02, Mixed mode)

Method Two: Install the JDK with Yum (CentOS)

1. See which JDK versions are available in the Yum Library

[email protected] ~]# Yum search java|grep jdkldapjdk-javadoc.x86_64:javadoc forLdapjdkjava-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.noarch:OpenJDK API Documentationjava-1.7.0-openjdk-Src.x86_64:OpenJDK Source Bundlejava-1.8.0-Openjdk.x86_64:OpenJDK Runtime Environmentjava-1.8.0-openjdk-Demo.x86_64:OpenJDK Demosjava-1.8.0-openjdk-Devel.x86_64:OpenJDK Development Environmentjava-1.8.0-openjdk-Headless.x86_64:OpenJDK Runtime Environmentjava-1.8.0-openjdk-Javadoc.noarch:OpenJDK API Documentationjava-1.8.0-openjdk-Src.x86_64:OpenJDK Source Bundleldapjdk.x86_64:The Mozilla LDAP Java SDK

2. Select version, install

[email protected] ~]# Yum install java-1.7. 0-openjdk

Note: The default installation directory is in:/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.75.x86_64

3. Setting Environment Variables

[Email protected] ~]# Vi/etc/profile

Enter VI edit model, add:

#Set  java environmentjava_home=/usr/lib/jvm/java-1.7. 0-openjdk-1.7. 0.75 . X86_64jre_home= $JAVA _home/jreclass_path=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar:$ jre_home/LibPATH= $PATH: $JAVA _home/bin: $JRE _home/binexport java_home jre_home class_path PATH

Let the changes take effect:

[Email protected] java]# Source/etc/profile

3. Verification, Ibid.

Method Three: Install the JDK with rpm

1. Download

[Email protected] ~]$ Curl-o http://download.oracle.com/otn-pub/java/jdk/7u79-b15/ jdk-7u79-linux-x64.rpm

2. Installing using the RPM command

[Email protected]  ~]# rpm-ivh jdk-7u79-linux-x64.rpmpreparing ...               ########################################### [%]  1: JDK                    ######## ###################################[]unpacking JAR files ...       Rt.jar ...       Jsse.jar ...       Charsets.jar ...       Tools.jar ...       Localedata.jar ... Jfxrt.jar ...

3. Setting Environment variables

[Email protected] java]# Vi/etc/profile

Go to VI Edit and add:

#Set  java environmentjava_home=/usr/java/jdk1. 7 . 0_79jre_home=/usr/java/jdk1. 7. 0_79/Jreclass_path=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar: $JRE _home/LibPATH = $PATH: $JAVA _home/bin: $JRE _home/binexport java_home jre_home class_path PATH

Let the changes take effect:

[Email protected] java]# java-"1.7.0_79"1.7. 0_79-   - 24.79-b02, Mixed mode)

Method Four: Install JDK on Ubuntu using Apt-get

1. See which JDK versions are available in the APT library

[Email protected]:~# apt-cache Search java|grep jdkdefault-JDK-Standard Java or Java compatible development Kitdefault-jdk-doc-Standard Java or Java Compatible development Kit (documentation) GCJ-4.6-JDK-GCJ and Classpath Development tools forJava (TM) gcj-JDK-GCJ and Classpath Development tools forJava (TM) openjdk-6-DBG-Java Runtime based on OpenJDK (debugging symbols) OpenJDK-6-demo-Java Runtime based on OpenJDK (demos and examples) OpenJDK-6-doc-OpenJDK Development Kit (JDK) documentationopenjdk-6-JDK-OpenJDK Development Kit (JDK) OpenJDK-6-jre-lib-OpenJDK Java Runtime (architecture Independent libraries) OpenJDK-6-source-OpenJDK Development Kit (JDK) source Filesopenjdk-7-DBG-Java Runtime based on OpenJDK (debugging symbols) OpenJDK-7-demo-Java Runtime based on OpenJDK (demos and examples) OpenJDK-7-doc-OpenJDK Development Kit (JDK) documentationopenjdk-7-JDK-OpenJDK Development Kit (JDK) OpenJDK-7-source-OpenJDK Development Kit (JDK) source Filesuwsgi-plugin-jvm-openjdk-6-Java Plugin forUwsgi (OpenJDK6) Uwsgi-plugin-jwsgi-openjdk-6-Jwsgi Plugin forUwsgi (OpenJDK6) OpenJDK-6-JRE-OPENJDK Java Runtime,usingHotspot jitopenjdk-6-JRE-HEADLESS-OPENJDK Java Runtime,usingHotspot JIT (headless) openjdk-7-JRE-OPENJDK Java Runtime,usingHotspot jitopenjdk-7-JRE-HEADLESS-OPENJDK Java Runtime,usingHotspot JIT (headless) openjdk-7-JRE-LIB-OPENJDK Java Runtime (architecture Independent libraries)

2. Select a version to install

[Email protected]:~# apt-get install openjdk-7-jdk

3. Setting Environment variables

[Email protected]:~# vi/etc/profile

Add the following content:

#Set  java environmentjava_home=/usr/lib/jvm/java-1.7. 0-openjdk-amd64jre_home= $JAVA _home/jreclass_path=.: $JAVA _home/lib/dt.jar: $JAVA _home /lib/tools.jar: $JRE _home/LibPATH= $PATH: $JAVA _home/bin: $JRE _home/binexport java_homejre_home Class_ Path Path

Let the changes take effect:

[Email protected]:~# source/etc/profile

4. Verification

[Email protected]:~# java-"1.7.0_79"2.5. 5) (7u79-2.5.  5-0ubuntu0. 12.04. 1  24.79-b02, Mixed mode)

Installing JDK under Linux

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.