Summary
Around Java, the general-purpose programming language, the next LTS (Long Term Support) version of OpenJDK, 21, was released last month, on 17 Sep. 2023 🎉
On Debian 12 - bookworm repositories, the current version is 17 aka the previous LTS.
This post shows how to install 21 manually on Devuan 5 - Daedalus based on Debian 12.
Alternatively, JDK 21 "x64 Debian Package" Oracle offers is available.
In addition, Just in order to taste the latest, Oracle offers Java 21 PlayGround, too, which doesn't require local installation.
Moreover, one of the easiest ways is to use "OpenJDK" Docker Official Image and its "21-bookworm" tag.
Environment
- OS: Devuan 5 Daedalus
- based on Debian 12 bookworm
- App Engine: OpenJDK 21
Tutorial
Get OpenJDK package
Visit: https://jdk.java.net/21/
You can get it there. I used the command line below:
$ 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 lines below, for example:
$ 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:
$ # checksum of the downloaded file
$ sha256sum openjdk-21_linux-x64_bin.tar.gz
a30c454a9bef8f46d5f1bf3122830014a8fbe7ac03b5f8729bc3add4b92a1d0a openjdk-21_linux-x64_bin.tar.gz
Place files
Extract it:
$ tar xzf openjdk-21_linux-x64_bin.tar.gz
The result is as below:
$ 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
Prepare PATH
and JAVA_HOME
.
As to PATH
:
$ # 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
:
$ # case bash
$ export JAVA_HOME=$(readlink -f .)
$ # case fish
$ #set -x JAVA_HOME $(readlink -f .)
Ready 🙌
Conclusion
Now Java 21 is in your hands:
$ 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:
$ nvim HelloWorld.java
Write below in it:
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, world.");
}
}
The way to execute it directly is as below:
$ java HelloWorld.java
Hello, world.
Yay. Next, try to compile it manually and run it:
$ 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 ☺
Top comments (0)