Three ways to install JDK under CentOS

Three ways to install JDK under CentOS#

Due to the different Linux development vendors, the operating details of the Linux version of different development vendors are different. Today, let's talk about the installation of JDK under CentOS:

Method 1: Manually decompress the JDK compressed package, and then set the environment variable##

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

[ root@localhost ~]# mkdir/usr/java
[ root@localhost ~]# cd /usr/java

  1. Download jdk, then unzip

[ root@localhost java]# curl -O http://download.Oracle.com/otn-pub/java/jdk/7u79-b15/jdk-7u79-linux-x64.tar.gz 
[ root@localhost java]# tar -zxvf jdk-7u79-linux-x64.tar.gz

  1. Set environment variables

[ root@localhost java]# vi /etc/profile

Add the following content to the profile:

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:

[ root@localhost java]# source /etc/profile

  1. Verify the validity of the JDK

[ root@localhost 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 2: Install JDK with yum

  1. Check which jdk versions are in the yum library (only openjdk is found for the time being)

[ root@localhost ~]# 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

  1. Select the version and install it

//Select version 1.7 to install
[ root@localhost ~]# yum install java-1.7.0-openjdk
//After installation, the default installation directory is: /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.75.x86_64

  1. Set environment variables

[ root@localhost ~]# vi /etc/profile

Add the following content in 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

[ root@localhost java]# source /etc/profile

  1. Verification (same method as above)

Method 3: Install JDK with rpm

  1. Download the rpm installation file

[ root@localhost ~]$ curl -O http://download.oracle.com/otn-pub/java/jdk/7u79-b15/jdk-7u79-linux-x64.rpm

  1. Install using rpm command

[ root@localhost  ~]# rpm -ivh jdk-7u79-linux-x64.rpm

  1. Set environment variables

[ root@localhost java]# vi /etc/profile

Add the following content to the opened 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

[ root@localhost java]# source /etc/profile

  1. Verification (same method as above)

Note: Similar to yum installation, you can run java commands without setting environment variables. The rpm installation method will install jdk to /usr/java/jdk1.7.0_79 by default, and then link to /usr/bin through a three-layer link, the specific link is as follows:

[ root@localhost ~]# cd /bin
[ root@localhost bin]# ll|grep java
lrwxrwxrwx. 1 root root    25 Mar 28 11:24 jar ->/usr/java/default/bin/jar
lrwxrwxrwx. 1 root root    26 Mar 28 11:24 java -> /usr/java/default/bin/java
lrwxrwxrwx. 1 root root    27 Mar 28 11:24 javac ->/usr/java/default/bin/javac
lrwxrwxrwx. 1 root root    29 Mar 28 11:24 javadoc ->/usr/java/default/bin/javadoc
lrwxrwxrwx. 1 root root    28 Mar 28 11:24 javaws ->/usr/java/default/bin/javaws
lrwxrwxrwx. 1 root root    30 Mar 28 11:24 jcontrol ->/usr/java/default/bin/jcontrol
[ root@localhost bin]# cd /usr/java/
[ root@localhost java]# ll
total 4
lrwxrwxrwx. 1 root root  16 Mar 28 11:24 default-> /usr/java/latest
drwxr-xr-x. 8 root root 4096 Mar 28 11:24 jdk1.7.0_79
lrwxrwxrwx. 1 root root  21 Mar 28 11:24 latest -> /usr/java/jdk1.7.0_79

Method 4: Use apt-get to install JDK on Ubuntu

  1. Check which jdk versions are available in the apt library

root@linuxidc:~# 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)

  1. Select version to install

root@linuxidc:~# apt-get install openjdk-7-jdk

  1. Set environment variables

root@linuxidc:~# vi /etc/profile

Add the following content to the opened 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

root@linuxidc:~# source /etc/profile

  1. Verification (same method as above)

Install JDK1.8.0_25 and configure environment variables on Ubuntu 14.04 http://www.linuxidc.com/Linux/2015-01/112030.htm

CentOS builds JDK environment http://www.linuxidc.com/Linux/2015-06/118879.htm

Install JDK1.8.0_25 and configure environment variables on Ubuntu 14.04 http://www.linuxidc.com/Linux/2015-01/112030.htm

Install Oracle JDK 1.8 on Ubuntu 14.04 LTS http://www.linuxidc.com/Linux/2014-11/109216.htm

CentOS6.3 install JDK and environment configuration http://www.linuxidc.com/Linux/2012-09/70780.htm

Install JDK8 on Ubuntu 14.04 http://www.linuxidc.com/Linux/2014-09/106218.htm

Install JDK graphic analysis under Ubuntu http://www.linuxidc.com/Linux/2014-09/107291.htm

This article permanently updates the link address: http://www.linuxidc.com/Linux/2016-09/134941.htm

Recommended Posts

Three ways to install JDK under CentOS
Three ways to install software under Ubuntu
Install Java JDK8 under CentOS6
How to install jdk1.8 on centOS7
[Introduction to redis] Install redis under Centos
CentOS install jdk
How to install offline JDK1.8 on centos7.0
Install mysql5.7 under CentOS7
Install ActiveMQ under Centos7
Install PostgreSQL12 under CentOS7
Install CentOS under VMware
Linux Centos7 install jdk1.8
CentOS7 install JDK8, tomcat8
Install mysql under Centos 7
Install Jenkins under Centos 7
Install MariaDB under MariaDB Centos7
Install mysql5.1 under CentOS6.5
Centos 7 install JDK (Linux install jdk)
CentOS Discovery Road 2---Use rpm to install JDK
How to install jdk1.8.0_151 and mysql5.6.38 on centos7.2.1511
CentOS 7 install JAVA environment (JDK 1.8)
Centos7.6 method to install Tomcat-8.5.39
Install Oracle11gR2 database under CentOS6.9
Install MySQL under Linux (CentOS 7)
Tencent Cloud Centos install jdk8
5.1. CentOS@ install JDK1.8 graphic tutorial
Install MongoDB database under CentOS7
CentOS 6.8 under linux install mongodb
Install Mesos tutorial under CentOS7
Centos 7 install jdk and package service service
How to install MySQL on CentOS 8
Install and configure keepalived under CentOS 5.9
Install JDK8 in rpm on CentOS7
Compile and install LAMP under Centos 5.2
How to install Memcached on CentOS 8
How to install FFmpeg on CentOS 8
How to install Virtualbox on CentOS 8
How to install TensorFlow on CentOS 8
Minimal install JDK 1.8 tutorial in CentOS 7
How to install TeamViewer on CentOS 8
How to install Perl 5 on CentOS
How to install Git on CentOS 8
How to install PHP7.4 in CentOS
How to install Gradle on CentOS 8
How to install Jenkins on CentOS 8
How to install Java on CentOS 8
How to install Go on CentOS 8
CentOS8 install jdk8 / java8 tutorial (recommended)
Linux CentOS 7 install JDK detailed steps
How to install GCC on CentOS 8
How to install Yarn on CentOS 8
How to install Nginx on CentOS 8
How to install Jenkins on CentOS 8
How to install Vagrant on CentOS 8
How to install Python 3.8 on CentOS 8
How to install Tomcat 9 on CentOS 8
How to install Webmin on CentOS 8
Install JDK1.8 original under Ubuntu Kylin
Install Harbor mirror warehouse under CentOS
How to install Ruby on CentOS 8
How to install Skype on CentOS 8