Arch Linux BasedManjaro

How To Install OpenJDK on Manjaro

Install OpenJDK on Manjaro

In this tutorial, we will show you how to install OpenJDK on Manjaro. OpenJDK is a versatile and widely-used open-source implementation of the Java Platform. Manjaro, a user-friendly and powerful Linux distribution, offers a seamless environment for software development, making it a perfect match for OpenJDK.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the OpenJDK on a Manjaro Linux.

Prerequisites

  • A server or desktop running one of the following operating systems: Manjaro, and other Arch-based distributions.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • Ensure that your Manjaro system is connected to the internet. This is crucial as it allows you to download the required packages and the OpenJDK installation script.
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install OpenJDK on Manjaro

Step 1. Before diving into the Webmin installation, it’s crucial to make sure your Manjaro system is up to date. Open a terminal and execute the following commands:

sudo pacman -Syu
sudo pacman -S base-devel

Step 2. Installing OpenJDK on Manjaro.

Now, it’s time to install OpenJDK. OpenJDK is available in multiple versions, and you can choose the one that suits your needs. Here, we will install the default version, which is OpenJDK 11:

sudo pacman -S jdk11-openjdk

To install a different version, replace jdk11-openjdk with the package name of your desired version. For example, to install OpenJDK 8, use jdk8-openjdk.

After installation, it’s crucial to verify that OpenJDK is correctly installed. You can do this by checking the version:

java -version

If the installation was successful, you’ll see information about the installed version. This confirms that OpenJDK is ready for use on your Manjaro system.

Step 3. Managing Multiple OpenJDK Versions.

Manjaro makes it easy to manage multiple OpenJDK versions. You may need different versions for various projects, and here’s how to handle them. To install multiple versions of OpenJDK, follow the same installation process as described in Step 2, but with different package names. For example, to install OpenJDK 8 and 11, run:

sudo pacman -S jdk8-openjdk
sudo pacman -S jdk11-openjdk

You can set a specific OpenJDK version as the active one for your system using the archlinux-java script. To switch to a different version, use the following command and select the version you want:

sudo archlinux-java set java-8-openjdk

Replace java-8-openjdk with the package name of the version you wish to switch to.

Setting a default version ensures that it’s automatically used for system-wide Java applications. To do this, use the archlinux-java script:

sudo archlinux-java set java-11-openjdk

Now, the selected version will be the default, simplifying your development process.

Step 4. Running a Simple Java Program.

To test OpenJDK further, create and run a basic Java program. Use your favorite text editor to write a simple “Hello, World!” program, like this:

public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}

Save the file with a .java extension. Then, compile and run it using the following commands:

javac HelloWorld.java
java HelloWorld

Congratulations! You have successfully installed OpenJDK. Thanks for using this tutorial to install the latest version of the OpenJDK on the Manjaro system. For additional help or useful information, we recommend you check the official OpenJDK website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to idroot.us, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button