

Install Java 12 (OpenJDK 12) on CentOS 7/6 & Fedora 30/29/28
source link: https://computingforgeeks.com/how-to-install-java-12-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.

This guide will discuss the steps needed to install Java 12 on CentOS 7/6 & Fedora 30/29/28. Java 12 reached General Availability on 19 March 2019 with Production-ready binaries released. Install JDK/OpenJDK 12 on your CentOS/Fedora system to configure Java development environment.
For Ubuntu, use How To Install Oracle Java 12 on Ubuntu
Install OpenJDK 12 on CentOS 7/6 & Fedora 30-27
OpenJDK is a free and open-source implementation of the Java Platform, Standard Edition licensed under the GNU General Public License version 2.
Fedora 30
Fedora 30 ships with OpenJDK 12 in its repositories. Install it by running the command.
sudo dnf install java-latest-openjdk java-latest-openjdk-devel
CentOS 7/6 & Fedora 29-27
For CentOS 7/6 & Fedora 29-27 visit JDK 12 releases page to download the latest version.
curl -O https://download.java.net/java/GA/jdk12.0.1/69cfe15208a647278a19ef0990eea691/12/GPL/openjdk-12.0.1_linux-x64_bin.tar.gz
Extract downloaded file using tar command.
tar xvf openjdk-12.0.1_linux-x64_bin.tar.gz
Move the resulting folder to /opt directory.
sudo mv jdk-12.0.1 /opt/
Configure Java environment:
cat <<EOF | sudo tee /etc/profile.d/jdk12.sh
export JAVA_HOME=/opt/jdk-12.0.1
export PATH=\$PATH:\$JAVA_HOME/bin
EOF
Source your profile file and check java
command
source /etc/profile.d/jdk12.sh
Confirm Java version.
$ echo $JAVA_HOME
/opt/jdk-12.0.1
$ java --version
openjdk 12.0.1 2019-04-16
OpenJDK Runtime Environment (build 12.0.1+12)
OpenJDK 64-Bit Server VM (build 12.0.1+12, mixed mode, sharing)
$ which java
/opt/jdk-12.0.1/bin/java
Install Java SE Development Kit 12 on CentOS 7/6 & Fedora 29-27
If you choose to go with Java SE Development Kit 12, download RPM package for CentOS / RHEL system using the command below.
curl -LO -H "Cookie: oraclelicense=accept-securebackup-cookie" \
"https://download.oracle.com/otn-pub/java/jdk/12.0.1+12/69cfe15208a647278a19ef0990eea691/jdk-12.0.1_linux-x64_bin.rpm"
Then install the package with the rpm
command:
$ sudo rpm -Uvh jdk-12.0.1_linux-x64_bin.rpm
warning: jdk-12.0.1_linux-x64_bin.rpm: Header V3 RSA/SHA256 Signature, key ID ec551f03: NOKEY
Preparing… ################################# [100%]
Updating / installing…
1:jdk-12.0.1-2000:12.0.1-ga ################################# [100%]
Confirm Java version installed
$ java -version
java version "12.0.1" 2019-04-16
Java(TM) SE Runtime Environment (build 12.0.1+12)
Java HotSpot(TM) 64-Bit Server VM (build 12.0.1+12, mixed mode, sharing)
Configure Java environment.
cat <<EOF | sudo tee /etc/profile.d/jdk12.sh
export JAVA_HOME=/usr/java/default
export PATH=\$PATH:\$JAVA_HOME/bin
EOF
To use Java Home, source the file.
source /etc/profile.d/jdk12.sh
Test Java Installation
Create a HelloWorld Java program.
$ cat HelloWorld.java
public class HelloWorld {
public static void main(String[] args) {
// Prints "Hello, World" to the terminal window.
System.out.println("Hello, World");
}
}
Compile Java code.
$ javac HelloWorld.java
Run your Java program.
$ java HelloWorld
Hello, World
Courses for Learning Java:
Choosing Default Version of Java
If you have more than one version of Java installed, you can set default one using alternatives command.
sudo alternatives --config java
For Java 11 installation, see our guides below.
How to Install Java 11 on CentOS 7 / Fedora
Recommend
-
5
Welcome to our guide on how to install MongoDB 4.2 on CentOS 7 / Fedora 31/30/29/28. MongoDB is an open source NoSQL database system written in C++. It is designed for high scalability, performance, and availability.Step 1: Update Sys...
-
13
How To Install Apache Tomcat 9 on CentOS 7Search ComputingForGeeksToday we’ll look at how you can install Ap...
-
10
How To Install Asterisk 16 LTS on CentOS 7Welcome to our guide on how to Install Asterisk 16 LTS on CentOS 7 / Fedora. Asterisk is a powerful Open Source PBX system with Enterprise features only available in commercially available PBX systems...
-
7
How To Install Node.js 13 on CentOS 7 & Fedora 32/31/30/29Node.js is a powerful open source JavaScript runtime built on Chrome’s V8 JavaScript engine for building fast and scalable network applications. Node.js 13 is available for Testers...
-
11
Install Java 11 on CentOS 7Search ComputingForGeeksThis article will help you to install Oracle Java 11 on C...
-
8
In this blog post, I’ll take you through the steps to Install Gulp.js on CentOS 7 / Fedora 29 / Fedora 28. Gulp is a toolkit that helps you automate painful or time-consuming tasks in your development workflow. Gulp has integrations built int...
-
18
Install Java 11 (OpenJDK 11) on RHEL 8This article will help you to install Oracle Java 11 on RHEL 8 / CentOS 8 / Rocky Linux 8. Java 11 is a long-term support (LTS) release which was made available to the General public on 25 September 2018...
-
12
Install Java 17 (OpenJDK 17) on Fedora 35/34/33/32Search ComputingForGeeksIn our today’s guide, we’ll talk a...
-
10
CentOS 8 & Fedora 34/33/32/31/30Are you looking for an easy way to install PHPUnit on CentOS 7 / CentOS 8 & Fedora 34/33/32/31/30/29?. PHPUnit is a unit testing framework for PHP applications. It is an instance of the xUnit architectu...
-
9
Install Temurin OpenJDK 17 on CentOS 7|RHEL 7|Oracle Linux 7Java is one of the highly used programming languages in the world. AdoptOpenJDK, also known as Eclipse Temurin is an open-source Java found...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK