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.

Installing Jabba

Click Jabba link to see more detailed information about Jabba

$ curl -sL | bash && . ~/.jabba/

Make sure to source in your environment if you skip it:

$ [ -s "$JABBA_HOME/" ] && source "$JABBA_HOME/"

If you don't have JAVA_HOME environment variable, run the following code:

$ echo 'export JAVA_HOME=$HOME/.jabba/jdk/openjdk@1.14.0-1/Contents/Home' >> ~/.bash_profile
$ echo 'export JAVA_HOME=$HOME/.jabba/jdk/openjdk@1.14.0-1/Contents/Home' >> ~/.bashrc
$ echo 'export JAVA_HOME=$HOME/.jabba/jdk/openjdk@1.14.0-1/Contents/Home' >> ~/.zshrc


# 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+
$ jabba install 1.8.0-custom=tgx+
$ jabba install 1.8.0-custom=zip+file:///opt/

# 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

Leave a Reply