How to Install Java on Arch Linux?
Java is one of the most popular programming languages. Today, many applications are using Java. Java consists of JRE (Java Runtime Environment) and JDK (Java Development Toolkit).
JRE is the Java Runtime Environment which is provided libraries to run and compile Java programs. JDK provides the compiler(javac) to compile the Java programs and other tools.
NOTE: We are installing the open implementation of Java i.e OpenJDK. Which is free and Open-Source implementation of Java SE (Standard Edition), it is maintained by Oracle, Red Hat and community. It is published under GPL 2.0 License
Procedure:
These are the steps which we will take to install JDK on our Arch based Linux Distribution
- Checking if Java is installed on the system
- Install JDK in Arch Linux
1 Specific Version
2 Latest Version - Verify the Java is installed or Not
Now let us discuss these steps in detail with commands to be used along with visual aids for better interpretation which are as follows:
Step 1: Check if java is installed on the system
First, we must check that java is installed or not on the system. And check which version is installed on the Arch Linux system. So to check the java is installed or not, we can use the following command as follows:
java -version
If the above command gives output as the command is not found, then Java is not installed on the Arch Linux system. Otherwise, you will see which version of JDK and JRE is installed.
You can also run this command in the terminal for verifying the same:
NOTE: This command is for checking the presence of Java compiler on the system
javac -verison
Step 2: Installing JDK in Arch Linux
Approach 1 (Specific Version)
Now we have to install a specific JDK package on the system. So first we will search which versions are available to download. To search for available JDK versions to download, use the following command as follows:
sudo pacman -sS java | grep jdk
Now we are going to install jre21-openjdk (21 version).
Current latest version : JDK 22 (as of May 2024)
sudo pacman -S jdk21-openjdk
After running the above command it will ask to proceed with installation or not then simply press ‘y’ key. Now you have successfully installed the JDK, including JRE .
Approach 2 (Latest Version)
Use the following command to install latest version OpenJDK:
sudo pacman -S jdk-openjdk
This will install the OpenJDK 22 (as of May 2024)
Step 3: Verifying the installation
I have installed OpenJDK 21
java -version && javac -version
Contact Us