Linux installation JDK

Source: Internet
Author: User

Because of the different Linux developers, so different developers of Linux version operation details are not the same, today, the installation of CentOS under the JDK:

Method One: Manually unzip the JDK's tarball and set the environment variable

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

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

2. Download the JDK, then unzip

[Email protected] java]# Curl-o http://download.Oracle.com/otn-pub/java/jdk/7u79-b15/jdk-7u79-linux-x64.tar.gz
[Email protected] java]# TAR-ZXVF jdk-7u79-linux-x64.tar.gz

3. Setting Environment variables

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

In profile, add the following:

#set Java Environment
java_home=/usr/java/jdk1.7.0_79
Jre_home=/usr/java/jdk1.7.0_79/jre
Class_path=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar: $JRE _home/lib
Path= $PATH: $JAVA _home/bin: $JRE _home/bin
Export Java_home jre_home Class_path PATH

Let the changes take effect:

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

4. Verifying JDK Validity

[Email protected] java]# java-version
Java Version "1.7.0_79"
Java (TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot (TM) 64-bit Server VM (build 24.79-b02, Mixed mode)

Method Two: Install the JDK with Yum

1. See which JDK versions are available in the Yum Library (OPENJDK only)

[email protected] ~]# Yum search Java|grep JDK
Ldapjdk-javadoc.x86_64:javadoc for LDAPJDK
JAVA-1.6.0-OPENJDK.X86_64:OPENJDK Runtime Environment
JAVA-1.6.0-OPENJDK-DEMO.X86_64:OPENJDK Demos
JAVA-1.6.0-OPENJDK-DEVEL.X86_64:OPENJDK Development environment
JAVA-1.6.0-OPENJDK-JAVADOC.X86_64:OPENJDK API Documentation
JAVA-1.6.0-OPENJDK-SRC.X86_64:OPENJDK Source Bundle
JAVA-1.7.0-OPENJDK.X86_64:OPENJDK Runtime Environment
JAVA-1.7.0-OPENJDK-DEMO.X86_64:OPENJDK Demos
JAVA-1.7.0-OPENJDK-DEVEL.X86_64:OPENJDK Development environment
JAVA-1.7.0-OPENJDK-JAVADOC.NOARCH:OPENJDK API Documentation
JAVA-1.7.0-OPENJDK-SRC.X86_64:OPENJDK Source Bundle
JAVA-1.8.0-OPENJDK.X86_64:OPENJDK Runtime Environment
JAVA-1.8.0-OPENJDK-DEMO.X86_64:OPENJDK Demos
JAVA-1.8.0-OPENJDK-DEVEL.X86_64:OPENJDK Development environment
JAVA-1.8.0-OPENJDK-HEADLESS.X86_64:OPENJDK Runtime Environment
JAVA-1.8.0-OPENJDK-JAVADOC.NOARCH:OPENJDK API Documentation
JAVA-1.8.0-OPENJDK-SRC.X86_64:OPENJDK Source Bundle
Ldapjdk.x86_64:The Mozilla LDAP Java SDK

2. Select a version to install

Select version 1.7 to install
[email protected] ~]# Yum install JAVA-1.7.0-OPENJDK
After the installation is complete, the default installation directory is:/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.75.x86_64

3. Setting Environment variables

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

Add the following content to the profile file

#set Java Environment
Java_home=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.75.x86_64
Jre_home= $JAVA _home/jre
Class_path=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar: $JRE _home/lib
Path= $PATH: $JAVA _home/bin: $JRE _home/bin
Export Java_home jre_home Class_path PATH

Let the changes take effect

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

4. Verification (Ibid. method)

Method Three: Install the JDK with rpm

1. Download RPM installation files

[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.rpm

3. Setting Environment variables

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

Add the following in the open profile file

#set Java Environment
java_home=/usr/java/jdk1.7.0_79
Jre_home=/usr/java/jdk1.7.0_79/jre
Class_path=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar: $JRE _home/lib
Path= $PATH: $JAVA _home/bin: $JRE _home/bin
Export Java_home jre_home Class_path PATH

Let the changes take effect

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

4. Verification (Ibid. method)

Note: Similar to yum installation, you can run Java commands without setting environment variables. The RPM installation method installs the JDK to/usr/java/jdk1.7.0_79 by default, and then links to/usr/bin via a three-layer link, as follows:

[[email protected] ~]# cd/bin
[[email protected] bin]# ll|grep java
lrwxrwxrwx. 1 root root  & nbsp Mar 11:24 jar->/usr/java/default/bin/jar
lrwxrwxrwx. 1 root root    April-11:24 Java-/usr /java/default/bin/java
lrwxrwxrwx. 1 root root    April 11:24 Javac->/usr/java/default/bin/javac
lrwxrwxrwx. 1 root root    Mar 11:24 javadoc->/usr/java/default/bin/javadoc
lrwxrwxrwx. 1 root root    Mar 11:24 javaws->/usr/java/default/bin/javaws
lrwxrwxrwx. 1 root root    April 11:24 Jcontrol->/usr/java/default/bin/jcontrol
[[email protected] bin]# cd/usr/java/
[[Email  protected] java]# ll
Total 4
lrwxrwxrwx. 1 root root -April 11:24 default->/usr/java/latest
Dr Wxr-xr-x. 8 root root 4096 Mar 11:24 jdk1.7.0_79
lrwxrwxrwx. 1 root root  April 11:24 Latest _79

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 JDK
Default-jdk-standard Java or Java compatible development Kit
Default-jdk-doc-standard Java or Java Compatible development Kit (documentation)
GCJ-4.6-JDK-GCJ and Classpath development tools for Java (TM)
GCJ-JDK-GCJ and Classpath development tools for Java (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) documentation
OPENJDK-6-JDK-OPENJDK Development Kit (JDK)
OPENJDK-6-JRE-LIB-OPENJDK Java Runtime (architecture Independent libraries)
OPENJDK-6-SOURCE-OPENJDK Development Kit (JDK) source files
Openjdk-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) documentation
OPENJDK-7-JDK-OPENJDK Development Kit (JDK)
OPENJDK-7-SOURCE-OPENJDK Development Kit (JDK) source files
Uwsgi-plugin-jvm-openjdk-6-Java plugin for UWSGI (OPENJDK 6)
Uwsgi-plugin-jwsgi-openjdk-6-Jwsgi plugin for UWSGI (OPENJDK 6)
OPENJDK-6-JRE-OPENJDK Java Runtime, using Hotspot JIT
OPENJDK-6-JRE-HEADLESS-OPENJDK Java Runtime, using Hotspot JIT (headless)
OPENJDK-7-JRE-OPENJDK Java Runtime, using Hotspot JIT
OPENJDK-7-JRE-HEADLESS-OPENJDK Java Runtime, using Hotspot 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 in the open profile file

#set Java Environment
Java_home=/usr/lib/jvm/java-1.7.0-openjdk-amd64
Jre_home= $JAVA _home/jre
Class_path=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar: $JRE _home/lib
Path= $PATH: $JAVA _home/bin: $JRE _home/bin
Export Java_home jre_home Class_path PATH

Let the changes take effect

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

4. Verification (Ibid. method)

Linux installation JDK

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.