Install Oracle JDK 10 on Arch Linux

28/12/2020
Oracle JDK is used by Java developers all over the world to develop, test Java applications. Oracle released version 10 of their JDK on March 20, 2018.  In this article, I will show you how to install Oracle JDK 10 on Arch Linux. Let’s get started.

Installing Oracle JDK 10 from AUR

First install Git with the following command:

$ sudo pacman -Sy git

Press y and then press <Enter> to continue.

Git should be installed.

Now go to ~/Downloads directory with the following command:

$ cd ~/Downloads

Now clone the Oracle JDK AUR repository with the following command:

$ git clone https://aur.archlinux.org/jdk.git

The Oracle JDK AUR repo should be cloned.

Now navigate to the jdk/ directory with the following command:

$ cd jdk/

Now run the following command to create a pacman package of Oracle JDK 10:

$ makepkg -s

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

It should take a while to generate the pacman package.

Once the pacman package is created, install it with the following command:

$ sudo pacman -U jdk*.pkg.tar.xz

Press y and then press <Enter> to continue.

Oracle JDK 10 should be installed.

Installing Oracle JDK 10 Manually

If you don’t like AUR, this section is for you.

Go to the official website of Java SE at https://www.oracle.com/technetwork/java/javase/overview/index.html

You should see the following page. Click on Downlods  as marked in the screenshot below.

Now you should see the following page. Click on Java Platform (JDK) 10 button as marked in the screenshot below.

You should see the following page. Now scroll down a little bit to the Java SE Development Kit 10 section.

Now click on the Accept License Agreement radio button.

Now click on the file which has Linux as Product/File Description and ends with tar.gz as marked in the screenshot below.

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

Your download should start.

Once the download is complete, navigate to the directory where you downloaded the file. For me it’s the ~/Downloads directory.

$ cd ~/Downloads

If you list the contents of the directory with ls -lh, you should see Oracle JDK 10 archive file as marked in the screenshot below.

Now extract the archive with the following command:

$ sudo tar xvzf jdk-10_linux-x64_bin.tar.gz -C INSTALL_DIR

Here, INSTALL_DIR is the directory where you want to extract the archive. In my case, it is the /opt directory. You may choose another directory if you wish.

The archive should be extracted.

Now if you list the contents of INSTALL_DIR directory, you should see a jdk-10/ directory as marked in the screenshot below.

Now you have to add INSTALL_DIR/jdk-10/bin to your PATH environment variable.

Run the following command to create a new file jdk10.sh in /etc/profile.d directory:

$ sudo nano /etc/profile.d/jdk10.sh

You should see the following window.

Now add the following lines to it.

export JAVA_HOME="INSTALL_DIR/jdk-10"
export PATH="$PATH:${JAVA_HOME}/bin"

NOTE: Be sure to change INSTALL_DIR to your specified directory. For me it’s /opt

Once you’re done, press <Ctrl> + x and then press y and then press <Enter> to save the file.

Now restart your computer with the following command:

$ sudo reboot

Once your computer starts, check whether JAVA_HOME is set with the following command:

$ echo $JAVA_HOME

As you can see it is set correctly.

Also check whether INSTALL_DIR/jdk-10/bin is in the PATH with the following command:

$ echo $PATH

As you can see in the marked section of the screenshot below, it is in the PATH.

Testing Oracle JDK 10

Now run the following command to check whether Oracle JDK is working:

$ java version

As you can see in the screenshot below, it is working correctly.

Now I will compile and run a simple Java program saved in HelloWorld.java file to show you that it works.

Contents of HelloWorld.java file:

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

First navigate to the directory where you saved HelloWorld.java file. In my case it is the ~/Documents/codes directory.

$ cd ~/Documents/codes

Now run the following command to compile the HelloWorld.java Java source file:

$ javac HelloWorld.java

Once the file is compiled, a HelloWorld.class file should be generated. This is the file you run.

Now you can run the HelloWorld.class file with the following command:

$ java HelloWorld

NOTE: Remember not to include .class extension when you run a Java program. It will not work if you do.

As you can see from the screenshot below, the correct output is displayed.

That’s how you install Oracle JDK 10 on Arch Linux. Thanks for reading this article.

ONET IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, ONET IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

Install Oracle JDK 11 on Ubuntu

The full form of JDK is Java Development Kit. It is used to write and test Java programs. Recently, JDK 11 came out. It...
29/12/2020

Install Latest Oracle Java JDK/JRE 7/8/9 on Linux

Oracle Java is the key foundation for every type of networked application developed. It is the global standard for developing...
28/12/2020

Install Oracle JDK 11 on Arch Linux

The full form of JDK is Java Development Kit. It is a set of tools used to compile, run, and debug Java applications. JDK...
29/12/2020
Bài Viết

Bài Viết Mới Cập Nhật

SỰ KHÁC BIỆT GIỮA RESIDENTIAL PROXY VÀ PROXY DATACENTER
17/02/2024

Mua Proxy v6 US Private chạy PRE, Face, Insta, Gmail
07/01/2024

Mua shadowsocks và hướng dẫn sữ dụng trên window
05/01/2024

Tại sao Proxy Socks lại được ưa chuộng hơn Proxy HTTP?
04/01/2024

Mua thuê proxy v4 nuôi zalo chất lượng cao, kinh nghiệm tránh quét tài khoản zalo
02/01/2024