DEV Community

nabbisen
nabbisen

Posted on β€’ Originally published at scqr.net

3 1 1 1

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

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Place files

Extract it:

$ tar xzf openjdk-21_linux-x64_bin.tar.gz
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

As to JAVA_HOME:

$ # case bash
$ export JAVA_HOME=$(readlink -f .)
$ # case fish
$ #set -x JAVA_HOME $(readlink -f .)
Enter fullscreen mode Exit fullscreen mode

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)
Enter fullscreen mode Exit fullscreen mode

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

$ nvim HelloWorld.java
Enter fullscreen mode Exit fullscreen mode

Write below in it:

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

The way to execute it directly is as below:

$ java HelloWorld.java
Hello, world.
Enter fullscreen mode Exit fullscreen mode

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.
Enter fullscreen mode Exit fullscreen mode

Hello, the latest Java on the latest Devuan ☺

πŸ‘‹ While you are here

Reinvent your career. Join DEV.

It takes one minute and is worth it for your career.

Get started

Top comments (0)

Great read:

Is it Time to go Back to the Monolith?

History repeats itself. Everything old is new again and I’ve been around long enough to see ideas discarded, rediscovered and return triumphantly to overtake the fad. In recent years SQL has made a tremendous comeback from the dead. We love relational databases all over again. I think the Monolith will have its space odyssey moment again. Microservices and serverless are trends pushed by the cloud vendors, designed to sell us more cloud computing resources.

Microservices make very little sense financially for most use cases. Yes, they can ramp down. But when they scale up, they pay the costs in dividends. The increased observability costs alone line the pockets of the β€œbig cloud” vendors.

πŸ‘‹ Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay