Java 21 on Devuan 5 (Debian 12): Install manually

Table of contents

Summary Summary

Around Java (opens in a new tab), the general-purpose programming language, the next LTS (Long Term Support) version of OpenJDK (opens in a new tab), 21 (opens in a new tab), was released last month, on 17 Sep. 2023 🎉

On Debian (opens in a new tab) 12 - bookworm (opens in a new tab) repositories (opens in a new tab), the current version is 17 aka the previous LTS.

This post shows how to install 21 manually on Devuan (opens in a new tab) 5 - Daedalus (opens in a new tab) based on Debian 12.


Alternatively, JDK 21 “x64 Debian Package (opens in a new tab)” Oracle (opens in a new tab) offers is available.

In addition, Just in order to taste the latest, Oracle offers Java 21 PlayGround (opens in a new tab), too, which doesn’t require local installation.

Moreover, one of the easiest ways is to use “OpenJDK” Docker Official Image (opens in a new tab) and its “21-bookworm” tag (opens in a new tab).

Environment Environment

  • OS: Devuan 5 Daedalus
    • based on Debian 12 bookworm
  • App Engine: OpenJDK 21

Tutorial Tutorial

Get OpenJDK package Get OpenJDK package

Visit: https://jdk.java.net/21/ (opens in a new tab)

You can get it there. I used the command lines below:

console
$ curl -LO https://download.java.net/java/GA/jdk21/fd2272bbf8e04c3dbaee13770090416c/35/GPL/openjdk-21_linux-x64_bin.tar.gz

You can verify the download by comparing the checksums between the server and the local. Use the command line below, for example:

console
$ echo "$(curl -s https://download.java.net/java/GA/jdk21/fd2272bbf8e04c3dbaee13770090416c/35/GPL/openjdk-21_linux-x64_bin.tar.gz.sha256) openjdk-21_linux-x64_bin.tar.gz" | \
      sha256sum -c
openjdk-21_linux-x64_bin.tar.gz: OK

It means it was confirmed that the server checksum was equal to the local one:

console
$ # checksum of the downloaded file
$ sha256sum openjdk-21_linux-x64_bin.tar.gz
a30c454a9bef8f46d5f1bf3122830014a8fbe7ac03b5f8729bc3add4b92a1d0a  openjdk-21_linux-x64_bin.tar.gz

Place files Place files

Extract it:

console
$ tar xzf openjdk-21_linux-x64_bin.tar.gz

The result is as below:

console
$ ls {.,jdk-21}
.:
jdk-21  openjdk-21_linux-x64_bin.tar.gz

jdk-21:
bin  conf  include  jmods  legal  lib  release

Now you have jdk-21 directory which contains bin etc. 👍

Set environment variables Set environment variables

Prepare PATH and JAVA_HOME.

As to PATH:

console
$ # case bash
$ export PATH=$(readlink -f ./jdk-21/bin):$PATH
$ # case fish
$ #set -x PATH $(readlink -f ./jdk-21/bin/):$PATH

As to JAVA_HOME:

console
$ # case bash
$ export JAVA_HOME=$(readlink -f .)
$ # case fish
$ #set -x JAVA_HOME $(readlink -f .)

Ready 🙌

Conclusion Conclusion

Now Java 21 is in your hands:

console
$ java --version
openjdk 21 2023-09-19
OpenJDK Runtime Environment (build 21+35-2513)
OpenJDK 64-Bit Server VM (build 21+35-2513, mixed mode, sharing)

Let’s do test run. Create a .java file:

console
$ nvim HelloWorld.java

Write below in it:

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

The way to execute it directly is as below:

console
$ java HelloWorld.java
Hello, world.

Yay. Next, try to compile it manually and run it:

console
$ ls HelloWorld*
HelloWorld.java

$ javac HelloWorld.java
$ # .class file is generated

$ ls HelloWorld*
HelloWorld.class  HelloWorld.java

$ java HelloWorld
Hello, world.

Hello, the latest Java on the latest Devuan ☺

More on: Web and back-end development

Scqr [secureal]

Scqr [secureal]: the engineering practice of Reflerd Inc. (opens in a new tab)

Comments and feedback are welcome.