How to install Java with Jabba

Runtime version managers make developers life easier. So, I tested different Java version managers. But, Jabba is the easiest one for me.

You can read previously posted How to install java articles.

Java Specification Versions:

Here are the major releases:

  1. Java 1.0 (January 1996) – The original version.
  2. Java 1.1 (February 1997) – Introduced several significant features, including the JavaBeans API.
  3. Java 2 (J2SE 1.2) (December 1998) – Introduced the Swing application framework.
  4. J2SE 1.3 (May 2000) – Introduced the HotSpot JVM.
  5. J2SE 1.4 (February 2002) – Introduced regular expressions, image I/O API, and more.
  6. Java SE 5 (J2SE 1.5) (September 2004) – Introduced generics, metadata annotations, enumerated types, and more.
  7. Java SE 6 (December 2006) – Introduced scripting support, JVM improvements, and more.
  8. Java SE 7 (July 2011) – Introduced the try-with-resources statement, the diamond operator, and more.
  9. Java SE 8 (March 2014) – Introduced lambdas, streams, and the java.time package.
  10. Java SE 9 (September 2017) – Introduced the module system.
  11. Java SE 10 (March 2018) – Introduced local-variable type inference (var).
  12. Java SE 11 (September 2018) – Introduced String::lines, isBlank, and other methods, plus the java.net.http HttpClient.
  13. Java SE 12 (March 2019) – Introduced switch expressions (preview) and more.
  14. Java SE 13 (September 2019) – Introduced text blocks (preview) and more enhancements.
  15. Java SE 14 (March 2020) – Introduced pattern matching for instanceof (preview) and other improvements.
  16. Java SE 15 (September 2020) – Continued the introduction and enhancement of several features.
  17. Java SE 16 (March 2021) – Introduced sealed classes (preview) and other enhancements.
  18. Java SE 17 (September 2021) – This version is an LTS (Long Term Support) release, which means it will receive updates for a longer period than the interim releases.
  19. Java SE 18 (March 2022)
  20. Java SE 19 (September 2022)
  21. Java SE 20 (March 2023)
  22. Java SE 21 (September 2023)

Java has moved to a time-driven release model, with new versions being released every six months. Not all of these are long-term support (LTS) versions. As of Java 17, the LTS versions have been Java 8, Java 11, and Java 17.

Installing or Upgrading Jabba

For more details in Jabba

$ curl -sL https://github.com/shyiko/jabba/raw/master/install.sh | bash && . ~/.jabba/jabba.sh

Usage

# list available JDK's
$ jabba ls-remote

# you can use any valid semver range to narrow down the list
$ jabba ls-remote zulu@~1.8.60
$ jabba ls-remote "*@>=1.6.45 <1.9" --latest=minor

# install Oracle JDK
$ jabba install 1.8

# install Oracle Server JRE
$ jabba install sjre@1.8

# install Adopt OpenJDK (Hotspot)
$ jabba install adopt@1.8-0

# install Adopt OpenJDK (Eclipse OpenJ9)
$ jabba install adopt-openj9@1.9-0

# install Zulu OpenJDK
$ jabba install zulu@1.8
$ jabba install zulu@~1.8.144 # same as "zulu@>=1.8.144 <1.9"

# install IBM SDK, Java Technology Edition
$ jabba install ibm@1.8

# install GraalVM CE
$ jabba install graalvm@1.0-0

# install OpenJDK
$ jabba install openjdk@1.10-0

# install OpenJDK with Shenandoah GC
$ jabba install openjdk-shenandoah@1.10-0

# install from custom URL
# (supported qualifiers: zip (since 0.3.0), tgz, tgx (since 0.10.0), dmg, bin, exe)
$ jabba install 1.8.0-custom=tgz+http://example.com/distribution.tar.gz
$ jabba install 1.8.0-custom=tgx+http://example.com/distribution.tar.xz
$ jabba install 1.8.0-custom=zip+file:///opt/distribution.zip

# uninstall JDK
$ jabba uninstall zulu@1.6.77

# link system JDK
$ jabba link system@1.8.72 /Library/Java/JavaVirtualMachines/jdk1.8.0_72.jdk

# list all installed JDK's
$ jabba ls

# switch to a different version of JDK (it must be already `install`ed)
$ jabba use adopt@1.8
$ jabba use zulu@~1.6.97

$ echo "1.8" > .jabbarc
# switch to the JDK specified in .jabbarc (since 0.5.0)
$ jabba use

# set default java version on shell (since 0.2.0)
# this version will automatically be "jabba use"d every time you open up a new terminal
$ jabba alias default 1.8

Listing all local installed JDK's

$ jabba ls

Listing all remove available JDK's

$ jabba ls-remote

Installing desired Java Version

$ jabba install openjdk@1.17.0

Set installed version as default in system

$ jabba alias default openjdk@1.17.0

Verify installation

$ java -version

openjdk 17 2021-09-14
OpenJDK Runtime Environment (build 17+35-2724)
OpenJDK 64-Bit Server VM (build 17+35-2724, mixed mode, sharing)

Leave a Reply