How to install latest Java version?

199 Views Asked by At

How do I use the latest version of Java in asdf without specifying a version number?

asdf install <name> latest

For example, I want to use Oracle GraalVM. I tried some operations but failed. How should I do it?

Here's what I did:

oracle-graalvm-21.0.1

This is the latest version and also what I need.

Try but failed:

asdf install java oracle-graalvm latest

Unknown release: oracle-graalvm

This works but I don't want to specify the version number:

 asdf install java oracle-graalvm-21.0.1
2

There are 2 best solutions below

0
On

I think asdf does not directly support the "latest" keyword for specific plugins. However, you can achieve a similar result using asdf-vm's plugin-alias feature.

# Add a plugin alias for Java
asdf plugin-add java https://github.com/halcyon/asdf-java.git

# Set an alias for the latest GraalVM version
asdf alias java latest graalvm-21.0.1

# Install the latest GraalVM version using the alias
asdf install java latest

# Set the latest GraalVM version as the global version
asdf global java latest
0
On

I was looking for the same. Taking a look at asdf-java, the syntax is as follows:

asdf install java latest:openjdk

You can also swap out the provider to be something else, like latest:graalvm

Hope that helps, happy coding!