6

Install Java 11 on CentOS 7 / Fedora 34/33/32/31/30/29

 2 years ago
source link: https://computingforgeeks.com/how-to-install-java-11-on-centos-fedora/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Install Java 11 on CentOS 7
Search

This article will help you to install Oracle Java 11 on CentOS 7 and Fedora 34/33/32/31/30/29. Java 11 is a long-term support (LTS) release. Java 11 was made available to the General public on 25 September 2018 and is production-ready.

There are two ways of installing Java 11 on CentOS 7 / Fedora 34/33/32/31/30/29.

  1. Install Java SE Development Kit 11 (JDK 11)
  2. Install OpenJDK 11

It is recommended to install OpenJDK 11 because of the license issues around Java SE Development Kit. This guide will cover the installation of both.

For Ubuntu & Debian, use: How to Install Java 11 on Ubuntu / Debian

Install OpenJDK 11 on CentOS 7 / Fedora

OpenJDK is a free and open-source implementation of the Java Platform, Standard Edition licensed under the GNU General Public License version 2.

Installing from OS repositories:

sudo yum install java-11-openjdk-devel

From OpenJDK 11 downloads page

Check the latest release of OpenJDK 11 before running the commands below:

curl -O https://download.java.net/java/GA/jdk11/9/GPL/openjdk-11.0.2_linux-x64_bin.tar.gz

After the download, extract the archive

tar zxvf openjdk-11.0.2_linux-x64_bin.tar.gz

Move the resulting folder to /usr/local/

sudo mv jdk-11.0.2/ /usr/local/

Set environment variables

sudo vim /etc/profile.d/jdk11.sh
export JAVA_HOME=/usr/local/jdk-11.0.2
export PATH=$PATH:$JAVA_HOME/bin

Source your profile file and check java command

$ source /etc/profile.d/jdk11.sh
$ java -version
openjdk version "11.0.2" 2019-01-15
OpenJDK Runtime Environment 18.9 (build 11.0.2+9)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.2+9, mixed mode)

$ which java
/usr/local/jdk-11.0.2/bin/java

Install Java SE Development Kit 11 (JDK 11) on CentOS 7 / Fedora

Download the latest release of JDK 11.

wget --no-cookies --no-check-certificate --header "Cookie: oraclelicense=accept-securebackup-cookie"   "http://download.oracle.com/otn-pub/java/jdk/11.0.2+9/f51449fcd52f4d52b93a989c5c56ed3c/jdk-11.0.2_linux-x64_bin.rpm"

Then install the package with the rpmcommand

$ sudo rpm -Uvh jdk-11.0.2_linux-x64_bin.rpm 
warning: jdk-11.0.2_linux-x64_bin.rpm: Header V3 RSA/SHA256 Signature, key ID ec551f03: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:jdk-11.0.2-2000:11.0.2-ga        ################################# [100%]

Confirm Java version installed

$ java -version 
java version "11.0.2" 2019-01-15 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.2+9-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.2+9-LTS, mixed mode)

Create an environment file

sudo vim /etc/profile.d/jdk.sh
export JAVA_HOME=/usr/java/default
export PATH=$PATH:$JAVA_HOME/bin

Source profile file to update changes

source /etc/profile

Choosing Default Version of Java

If you have other versions of JDK installed, you set your default Java as follows.

# alternatives --config java

Video Courses to Learn Java Programming Language:

Also check:  How to Install Java 11 on Ubuntu / Debian


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK