How to install Java on Manjaro Linux

Many developers and programmers choose Manjaro because it’s one of the most user-friendly and feature-rich Linux distributions. In this guide, we go over the steps to install the Java Development Kit on Manjaro Linux. We’ll show you how to install both the OpenJDK package (which is free and GPL-licensed) as well as Oracle Java SE Development Kit.

Arch Linux and Manjaro only officially support the OpenJDK, as that is the non-proprietary version. However, the Oracle package can be installed from the AUR, as you’ll see shortly.

In this tutorial you will learn:

  • How to install OpenJDK
  • How to install Oracle Java SE Development Kit
  • How to test Java installation

We have successfully compiled and run our Hello World program using OpenJDK on Manjaro

We have successfully compiled and run our Hello World program using OpenJDK on Manjaro

Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Manjaro Linux
Software OpenJDK, Oracle Java SE Development Kit
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

Install OpenJDK



All of the OpenJDK packages can be installed in terminal with pacman. The packages you need will depend on what kind of programs you’re developing. We’ll go through all the options below. You can also choose between version 7, 8, 11, or 14 from the official repositories.

  • Headless JRE = minimal Java runtime, used for executing non-GUI Java programs.
  • Full JRE = full Java runtime, used for executing GUI Java programs.
  • JDK = Java Development Kit, always needed for developing Java programs.
  • Documentation = JDK help pages.
  • Sources = JDK source files.

The following commands will install the five packages as explained above. Use the appropriate one for whichever Java version you wish to install.

Install OpenJDK 14

$ sudo pacman -S jre-openjdk-headless jre-openjdk jdk-openjdk openjdk-doc openjdk-src

Install OpenJDK 11

$ sudo pacman -S jre11-openjdk-headless jre11-openjdk jdk11-openjdk openjdk11-doc openjdk11-src

Install OpenJDK 8

$ sudo pacman -S jre8-openjdk-headless jre8-openjdk jdk8-openjdk openjdk8-doc openjdk8-src

Install OpenJDK 7

$ sudo pacman -S jre7-openjdk-headless jre7-openjdk jdk7-openjdk openjdk7-doc openjdk7-src

Install Oracle Java SE Development Kit

In order to install Oracle Java, Manjaro will need access to the Arch User Repository (AUR), as Oracle Java is not available in any official repository. You can install a package from the AUR by configuring access to it in pamac or installing an AUR helper like yay. It’s also possible to use git and makepkg to download AUR packages manually, but the process is much more concise if we just use yay, so that’s the method we’ll be using below.

Install Oracle Java 14



$ yay -S jre jdk

Install Oracle Java (any other version)

You can simply append any version number to the jre and jdk packages to install a different version from the current one (14). For example:

$ yay -S jre11 jdk11

or

$ yay -S jre8 jdk8

etc…

An alternative is to navigate to Oracle’s website and download the desired Java package directly from there.

Downloading Oracle Java from the official website

Downloading Oracle Java from the official website

Test Java Installation

You can check if Java is installed and see what version you’re running by executing this command:

$ java -version


Checking Java version from terminal

Checking Java version from terminal

Additionally, you may test your Java installation by compiling Java Hello World program.

We have successfully compiled and run our Hello World program using OpenJDK on Manjaro

We have successfully compiled and run our Hello World program using OpenJDK on Manjaro

Conclusion

In this guide, we learned how to install Java OpenJDK as well as Oracle Java SE Development Kit on Manjaro Linux. We also saw how to install different versions and a couple different methods for installaton. Lastly, we tested our installation by checking the version number and compiling a test program. Now you will be able to develop all manner of Java programs on your Manjaro system.



Comments and Discussions
Linux Forum