Java is a popular object-oriented programming language used for building applications.
To run and develop an application in Java, you need to install the Java Development Kit (JDK). There are two different implementations of JDK – OpenJDK and Oracle JDK.
Edit: Thanks for all the responses. I don't know how I missed this. For some context, I've been a Java dev for the same company for 6+ years, and looking back, I guess I never directly downloaded the JDKs. Just started a new job and have a fresh computer, so was trying to download and was baffled by the sign-in page.
In this guide, learn how to install Java on a CentOS 8 server, including the OpenJDK and the Oracle JDK implementation.
Open JDK is the free version of Java that consists of the Java Runtime Environment (JRE) and Development Tools. To run and develop Java applications, you need to install the complete package with its development kit.
Currently, there are two LTS versions of OpenJDK – OpenJDK 8 and OpenJDK 11. Oracle supports and updates both versions regularly. Although new releases come out every six months, they are maintained only until the next release. Therefore, it is not advisable to install anything other than version 8 or version 11 unless you have a good reason to do so.
Note: You can have more than one version of Java installed on your system. That's helpful if you’re working on different projects that require different Java versions. Such configuration requires you specify the Java environment each time you work on a project.
Open a terminal window and enter the following:
Confirm any prompts, allow the process to finish, and verify the installation with:
To install the older LTS version, OpenJDK 8, use the following command:
Verify Java version 8 is now installed with:
If you are not developing in Java, but still need to run Java applications, you can skip installing the JDK and set up the Java Runtime Environment (JRE).
JRE is a combination of a Java Virtual Machine (JVM) and the libraries required for executing the code in runtime. It is the minimum requirement for running any Java application.
Just like with the Development Kit, there are two LTS versions of the Runtime Environment – JRE 8 and JRE 11.
To install JRE 11, run:
To install JRE 8, use the command:
Note: Remember - You don't need to install OpenJRE if you already have OpenJDK. The Runtime Environment comes with the Java Development Kit by default.
Another alternative to OpenJDK is only installing the headlessversion.
Just like OpenJRE, Java headlessis part of OpenJDK and should not be installed on top of it.
The headless option is a minimal runtime environment, without a graphical interface, more suitable for server applications. It uses minimal system resources and doesn’t include keyboard or mouse support.
Install OpenJDK 11 headlessby entering the following:
For OpenJDK 8 headlessrun:
When installing Oracle Java on CentOS 8, make sure to download directly from the official source, Oracle. This requires creating an account on the Oracle website.
1. Open a web browser and navigate to the Oracle download page. Here you will find all the Java download links for different versions of Java SE.
Note: Java SE is the Standard Edition of the software, mainly used for developing portable desktop apps. An alternative to Java SE is Java Enterprise Edition (Java EE), more suitable for enterprise-level development. /microsoft-office-for-mac-109-5-free-download.html.
2. Scroll down to see different versions of Java SE and find the one you need. In this article, we are sticking to the LTS release – Java 11.
The Java SE 11.0.5 (LTS) section includes a download button to install Oracle JDK (Java Development Kit). Unlike in the previous versions, this edition doesn’t offer the possibility to download Oracle JRE (Java Runtime Environment) as a separate package.
3. Click the blue Download button on the right, just below the Oracle JDK heading.
4. The link takes you to the next page of the download section and informs you about the Oracle JDK License Update. Make sure to review it before you download the software.
5. Scroll down and find the gray box labeled Java SE Development Kit 11.0.5. In it, you will find all the available packages for the software.
6. To download any of the packages, you first need to check the box that confirms you Accept License Agreement.
7. For CentOS 8, the Linux x64 .rpm file is a good package choice since it is easier to install. If you’re running a 32-bit operating system, use Linux x86.
8. To gain access to the file, log in with your Oracle account.
9. Allow the download to finish. Once it’s complete, open the terminal and enter the following:
Note: Replace userwith the actual username. Additionally, if your filename is different, use the filename of your download.
9. Once the installation finishes, you can check the Java version with the following:
You might have 2 different versions of Java on your system. To set one as the default , use the command:
The system displays a list of different Java versions. If you like the default, press Enter.
If you want to change it, type the number of the version you want, then press Enter. Free download spss 16 full version.
With the default version set, you can configure JAVA_HOME on your CentOS 8.
By doing so, applications compiled in this programming language can easily access Java’s installation path.
How you define the JAVA_HOME environment depends on which version of Java you have. To define the location of Java 8 or Java 11, refer to phoenixNAP’s instructional guide on How to Set JAVA_HOME Environment Variable.
You should now have one (or more) versions of Java running on CentOS 8.
REmember, if you only need support for running Java applications, choose JRE (Java Runtime Environment). Install JDK (Java Developer Kit) if you need to create Java applications.
In general, your system will be more stable for longer if you choose a LTS (Long-Term Support) version.
Next you should also read
Python is a popular programming language used to write scripts for operating systems, but also web…
As a highly popular programming language, Java is used for developing anything from lightweight mobile to…
Java is one of the most popular programming languages used for developing anything from lightweight mobile to…
Python is a popular, stable, and well-performing programming language. CentOS 7 uses Python 2.7.5, but as…