Install Openjdk Linux Centos

Step bt StepTutorial Learn How to Install Java on CentOS 7. We cover all versions including JDK 8, 11, and Oracle verison 12. Get started with Java! Openjdk version '14' 2020-03-30 OpenJDK Runtime Environment (build ) OpenJDK 64-Bit Server VM (build, mixed mode, sharing) Step 2: Installing Java SE Development Kit 14 on CentOS 8. As in one step we’ve installed the Java 14 using curl now we’ll install the Java SE Development Kit 14 on CentOS 8.

  1. Centos 8 Install Openjdk
  2. Centos 7 Install Openjdk 8
  3. Install Openjdk 11 On Centos 6
Java Development Kit (JDK) is used to develop and test Java applications. It is used by millions of Java developers around the world.

JDK has 2 versions. OpenJDK and Oracle JDK. OpenJDK is an open source implementation of Oracle JDK. Oracle JDK contains some proprietary codes that OpenJDK does not have. OpenJDK is open source where Oracle JDK is not.

In this article, I am going to show you how to install Oracle JDK 12 and OpenJDK 12 on CentOS 7. So, let’s get started.

Oracle JDK 12 is not available in the official package repository of CentOS 7. But, you can easily download Oracle JDK 12 from the official website of Oracle and install it on CentOS 7.

First, visit https://www.oracle.com/technetwork/java/javase/downloads/index.html from your favorite browser. Once the page loads, click on the DOWNLOADJava Platform (JDK) 12 button as marked in the screenshot below.

Now, click on Accept License Agreement to accept the Oracle Technology Network License Agreement for Oracle Java SE.

Your browser should prompt you to save the file. Select Save File and click on OK.

jdk 12.0.1 RPM package is being downloaded.

Once the download is complete, navigate to the ~/Downloads directory as follows:

As you can see, the RPM package file I just downloaded is here.

Now, install the RPM package file with the following command:

Install

Oracle JDK 12 is being installed.

Oracle JDK 12 should be installed at this point.

Now, to check that the installation was successful and Oracle JDK 12 is working, run the following command:

As you can see, Oracle JDK 12 is working.

Installing OpenJDK 12:

OpenJDK 12 is not available in the official package repository of CentOS 7. But, you can easily download it from the official website of OpenJDK and install it on CentOS 7.

To download OpenJDK 12, visit https://jdk.java.net/12/ from your favorite web browser and click on the .tar.gz link as marked in the screenshot below.

Your browser should prompt you to save the OpenJDK 12 .tar.gz archive. Select Save File and click on OK.

Your browser should start downloading OpenJDK 12 archive. It may take a while to complete.

Once the download is complete, navigate to the ~/Downloads directory with the following command:

As you can see, the OpenJDK 12 archive you’ve just downloaded is here.

Now, extract the OpenJDK 12 archive in the /opt directory with the following command:

$ sudotar xvzf openjdk-12.0.1_linux-x64_bin.tar.gz -C/opt
Install Openjdk Linux Centos

The OpenJDK 12 archive should be downloaded.

As you can see, a new directory is created in the /opt directory. Note the directory name.

Now, you have to add the JAVA_HOME environment variable and add the OpenJDK 12 binary directory to the PATH environment variable. To do that, run the following command:

$ echo-e'export JAVA_HOME='/opt/jdk-12.0.1'nexport PATH='$PATH:${JAVA_HOME}/bin'n'|
sudotee/etc/profile.d/openjdk12.sh

A new file /etc/profile.d/openjdk12.sh should be created.

Now, reboot your computer with the following command:

Once your computer boots, run the following command to check whether the environment variables JAVA_HOME and PATH is set correctly.

As you can see, the environment variables are correctly set.

Now, check whether OpenJDK 12 is working correctly with the following command:

Install openjdk linux centos linux

Centos 8 Install Openjdk

OpenJDK version 1.8.0_212! This is not the version we installed.

The problem is another version of OpenJDK is installed on your CentOS 7 machine. To solve this problem, just remove the old OpenJDK packages from your CentOS 7 machine as follows:

Now, press y and then press <Enter> to continue.

The older version of OpenJDK should be removed.

As you can see, now the version is correctly displayed. So, the OpenJDK we’ve installed earlier is being used.

Compiling and Running a Simple Java Program with JDK 12:

Rhel install openjdk

Centos 7 Install Openjdk 8

In this section, I am going to compile and run a simple Java program with JDK 12.

I wrote a simple Java program in a file Welcome.java and put it in the ~/codes directory on my login users HOME directory.

Install Openjdk 11 On Centos 6

The contents of the Welcome.java Java source file are:

publicclass Welcome {
publicstaticvoid main(String[] args){
System.out.println('Welcome to LinuxHint!');
}
}

First, navigate to the directory where the Welcome.java source file is.

Then, to compile the Welcome.java Java source file, run the following command:

Once the Welcome.java source file is compiled, a Welcome.class file should be generated. This is a Java class file. It contains Java bytecodes that the Java Virtual Machine (JVM) can understand.

As you can see, the correct output is displayed.

So, that’s how you install Oracle JDK 12 and OpenJDK 12 on CentOS 7. Thanks for reading this article.

  • Install / Initial Config
  • NTP / SSH Server
  • DNS / DHCP Server
  • Storage Server
  • Virtualization
  • Cloud Compute
    • (15) Configure Horizon
  • Container Platform
  • Directory Server
  • WEB Server
  • Database
    • Redis
    • MySQL 8.0
    • PostgreSQL 12
    • MariaDB 10.3
    • SQL Server 2019
    • Oracle Database 19c
  • FTP / Samba / MAIL
  • Proxy / Load Balancer
  • Monitoring
    • Monitorix
    • OSQuery
    • MRTG
    • Cacti
    • Munin
    • Sensu
    • Nagios
    • SysStat
    • Zabbix 4.2
    • Zabbix 4.0 LTS
  • Lang / Development
    • Scala
    • TensorFlow
    • CUDA
    • Ruby
    • Node.js
    • PHP
    • Python
    • .NET Core
    • Java
  • Desktop Environment
  • Others #1
    • Zarafa - Groupware
    • Zimbra - Groupware
    • Bacula - Backup
    • Subversion - Revision Control
    • Gitolite3 - Revision Control
    • RabbitMQ - Message Broker
    • Memcached - Memory Cache
    • ElasticStack - Search Engine++
    • Func - Remote Manage
    • Salt - Config Manage
    • Puppet - Config Manage
    • Ansible - Config Manage
    • Spacewalk - System Manage
    • Pacemaker - HA Cluster
    • PXE Boot- PXE Server
    • OpenVPN - VPN Server
    • LVM - LVM Manage
    • Rsyslog - Syslog Server
    • Cgroups - Resource Control
    • Auditd - System Audit
    • SELinux - Access Control
    • Firewalld - Packet Filter
  • Others #2