Java 21 - how to install early_access version
I want to try Java 21!
You can easily try out the new features in Java 21 that I wrote about in the previous post. You don’t need to install anything. Just follow these steps:
- Download and unzip the archive.
- Set the JAVA_HOME variable to point to it.
- Add the /bin subdirectory to your PATH variable.
Let’s do it step by step
Here’s how to do it in Ubuntu Linux:
You will find a list of packages to download: the jdk archive and the checksum file (sha256).
Download the archive
Download .zip or .tar.gz appropriate for your operating system and architecture (and additionally download .sha256 for verification). In the commandline you an use wget with following options:
- -c (continiue downloading to “partial” file)
- -t0 (…retry again and again until you get it)
Untar/unzip the archive
Untar or unzip the archive file which was downloaded in the previous step (either
.tar.gz) to a local directory (for example, to ~/prog - this is your JDK location)
I downloaded .tar.gz file, so I need to extract it like this:
Configure the environment
- set your environment variable JAVA_HOME so that it points to JDK
- add /bin subdirectory from your JDK installation to PATH
This is part of my shell configuration file (I use zsh):
Verify if everything works as it should
Check the version
Try to compile
Try to compile the simplest possible hello world java program :)
Installing Java for exploratory purposes is quite simple. If you don’t mind that - after following the above instructions - Java 21 will be the default Java version, don’t hesitate to give it a try. In September, you can expect Java 21 to be available in package managers. Once it’s officially released:
- Return to these instructions.
- Undo the changes (remove the downloaded and unzipped archive).
- Install Java properly.
- Update the environment variables :)