Install Java on Arch

Install OpenJDK 11 using pacman

Arch linux has a package manager called pacman. You can find openjdk in pacman repository. However the latest version of openjdk is 11.

You can install openjdk 11 using following command

$ sudo pacman -S jdk11-openjdk

You will see following logs that show you the openjdk dependencies. It also prompts to proceed or now.

resolving dependencies…
looking for conflicting packages…
warning: dependency cycle detected:
warning: harfbuzz will be installed before its freetype2 dependency
Packages (17) freetype2-2.10.1-1  giflib-5.1.9-3  graphite-1:1.3.13-1  harfbuzz-2.5.3-1  hicolor-icon-theme-0.17-1
               java-environment-common-3-1  java-runtime-common-3-1  jre11-openjdk-11.0.4.u7-1  jre11-openjdk-headless-11.0.4.u7-1
               lcms2-2.9-1  libjpeg-turbo-2.0.2-1  libnet-1.1.6-3  libpng-1.6.37-1  libtiff-4.0.10-1  nspr-4.21-1  nss-3.44.1-1
               jdk11-openjdk-11.0.4.u7-1
Total Download Size:   113.27 MiB
Total Installed Size:  264.64 MiB
:: Proceed with installation? [Y/n]

Type Y character and enter. This is how the installation logs looked like for me.

:: Retrieving packages…
  nspr-4.21-1-x86_64                                          189.2 KiB   281K/s 00:01 [#################################################] 100%
  nss-3.44.1-1-x86_64                                        1364.1 KiB   398K/s 00:03 [#################################################] 100%
  java-runtime-common-3-1-any                                   4.7 KiB  0.00B/s 00:00 [#################################################] 100%
  libjpeg-turbo-2.0.2-1-x86_64                                422.5 KiB  1806K/s 00:00 [#################################################] 100%
  libtiff-4.0.10-1-x86_64                                     807.9 KiB   878K/s 00:01 [#################################################] 100%
  lcms2-2.9-1-x86_64                                          186.6 KiB  26.0M/s 00:00 [#################################################] 100%
  libnet-1.1.6-3-x86_64                                        91.8 KiB  14.9M/s 00:00 [#################################################] 100%
  libpng-1.6.37-1-x86_64                                      237.5 KiB  23.2M/s 00:00 [#################################################] 100%
  graphite-1:1.3.13-1-x86_64                                  222.4 KiB  31.0M/s 00:00 [#################################################] 100%
  harfbuzz-2.5.3-1-x86_64                                     729.9 KiB  1423K/s 00:01 [#################################################] 100%
  freetype2-2.10.1-1-x86_64                                   459.8 KiB  1625K/s 00:00 [#################################################] 100%
  jre11-openjdk-headless-11.0.4.u7-1-x86_64                    31.9 MiB  1756K/s 00:19 [#################################################] 100%
  giflib-5.1.9-3-x86_64                                        78.1 KiB  25.4M/s 00:00 [#################################################] 100%
  jre11-openjdk-11.0.4.u7-1-x86_64                            176.0 KiB  17.2M/s 00:00 [#################################################] 100%
  java-environment-common-3-1-any                               2.4 KiB  0.00B/s 00:00 [#################################################] 100%
  hicolor-icon-theme-0.17-1-any                                10.7 KiB  0.00B/s 00:00 [#################################################] 100%
  jdk11-openjdk-11.0.4.u7-1-x86_64                             76.5 MiB  1547K/s 00:51 [#################################################] 100%
 (17/17) checking keys in keyring                                                      [#################################################] 100%
 (17/17) checking package integrity                                                    [#################################################] 100%
 (17/17) loading package files                                                         [#################################################] 100%
 (17/17) checking for file conflicts                                                   [#################################################] 100%
 (17/17) checking available disk space                                                 [#################################################] 100%
 :: Processing package changes…
 ( 1/17) installing java-runtime-common                                                [#################################################] 100%
 For the complete set of Java binaries to be available in your PATH,
 you need to re-login or source /etc/profile.d/jre.sh
 Please note that this package does not support forcing JAVA_HOME as former package java-common did
 ( 2/17) installing nspr                                                               [#################################################] 100%
 ( 3/17) installing nss                                                                [#################################################] 100%
 ( 4/17) installing libjpeg-turbo                                                      [#################################################] 100%
 ( 5/17) installing libtiff                                                            [#################################################] 100%
 Optional dependencies for libtiff
     freeglut: for using tiffgt
 ( 6/17) installing lcms2                                                              [#################################################] 100%
 ( 7/17) installing libnet                                                             [#################################################] 100%
 ( 8/17) installing libpng                                                             [#################################################] 100%
 ( 9/17) installing graphite                                                           [#################################################] 100%
 (10/17) installing harfbuzz                                                           [#################################################] 100%
 Optional dependencies for harfbuzz
     cairo: hb-view program
 (11/17) installing freetype2                                                          [#################################################] 100%
 (12/17) installing jre11-openjdk-headless                                             [#################################################] 100%
 Optional dependencies for jre11-openjdk-headless
     java-rhino: for some JavaScript support
 (13/17) installing giflib                                                             [#################################################] 100%
 (14/17) installing jre11-openjdk                                                      [#################################################] 100%
 when you use a non-reparenting window manager,
 set _JAVA_AWT_WM_NONREPARENTING=1 in /etc/profile.d/jre.sh
 Optional dependencies for jre11-openjdk
     alsa-lib: for basic sound support
     gtk2: for the Gtk+ 2 look and feel - desktop usage
     gtk3: for the Gtk+ 3 look and feel - desktop usage
 (15/17) installing java-environment-common                                            [#################################################] 100%
 (16/17) installing hicolor-icon-theme                                                 [#################################################] 100%
 (17/17) installing jdk11-openjdk                                                      [#################################################] 100%
 :: Running post-transaction hooks…
 (1/1) Arming ConditionNeedsUpdate…

Use java -version to verify openjdk installation

java -version
openjdk version "11.0.4" 2019-07-16
OpenJDK Runtime Environment (build 11.0.4+7)
OpenJDK 64-Bit Server VM (build 11.0.4+7, mixed mode)

Install openjdk 12 manually

The first step is downloading the openjdk binary archive file. The official openjdk website is https://jdk.java.net and you can download the openjdk version you are looking for from https://jdk.java.net/archive/.

To download openjdk 12 binary archive file in arch you can use following command. Download it in a place you are going to extract it. For manual installation of an application in linux, linux admins use mostly /opt folder. However you root access for any write access. That means you need run linux command as sudo user.

Make sure you have wget cli tool installed, if not you can use sudo pacman -S wget to install it

$ cd /opt
$ sudo mkdir java
$ cd java
$ sudo wget https://download.java.net/java/GA/jdk12/33/GPL/openjdk-12_linux-x64_bin.tar.gz

After downloading the .tar.gz archive file, you can use tar -xfv to extract it in /opt

sudo tar -xvf openjdk-12_linux-x64_bin.tar.gz

After extracting I recommend use jEnv to set JAVA_HOME and PATH variables. Refer to Switching JDKs using jEnv for more information

Leave a Reply