Jim Lynch Codes
  • Blog
  • About Jim

Writings about one coder's stories & experiences.

Easily Install & Switch between Java Versions With Jabba

5/7/2020

0 Comments

 
Although Java is one of my favorite languages to dump on, I have been using Java for Exercism.io problems. Not only have I been trying to get some in with Java itself, but other languages like Clojure and CFML depend on have some version of Java installed on your system, either just the runtime environment (JRE) or the whole development kit (JDK). In this post I'll talk about Jabba, my new favorite cli tool for installing and switching Java versions!

Pains & Desires

This whole thing started because on my macbook I had java 14 installed with brew:
brew install java
However, I was trying to run things that, "only worked in Java 8-13", I didn't really want to mess around with uninstalling and reinstalling every time. I just wanted something that was easy and simple like node's nvm. It was during a google search similar to that when I originally found Jabba. Jabba even describes itself right at the top of its README as, "inspired by nvm"! When I started using it I thought to myself "Hey, think isn't so bad".

Installing Jabba

You should probably use the command in the instructions in the Jabba repo, but I'm on macOs 10.15.3 and run this to install it:
curl -sL https://github.com/shyiko/jabba/raw/master/install.sh | bash && . ~/.jabba/jabba.sh
You may need to start a new shell in order to have the jabba command available, but you should be able to just say "jabba":
jabba
This should give you a whole bunch of output about how to use jabba (rather than an error that the command was not found).

​To see the version of jabba installed:
jabba --version

To see ALL the available versions of Java:
jabba ls-remote

To see all the versions of Java 13:
jabba ls-remote | grep @1.13

Then choose the Java distribution you like and install the latest version.​
Picture

For example looking at the above choices you might choose "openjdk@1.13.0-2".

You can install it through jabba with this command:
java install openjdk@1.13

​This will install the latest 1.13.X version of the openjdk flavor of Java, which is 1.13.0 (keep in mind that the dashes represent pre-releases). It should automatically switch your current shell's Java version to the version you just installed as well.

To check the current Java version you're using: 
java --version

Suppose though that you open a new shell that defaults back to Java 14. You already have Java 13 installed, so you just need to use it:
jabba use openjdk@1.13.0

Final Remarks

I think jabba is a great tool. I'm afraid I'd say it's not totally as nice to use as nvm is, but it'll do just fine. Part of the confusion comes from all the various different flavors of Java, which can be overwhelming sometimes and the interesting version scheme to always use "1" as the major version. 

By contrast, with nvm you can run these two short and sweet commands:
nvm i v13
nvm use v13

Sadly, jabba doesn't support the "i" alias for install, you gotta type that baby out every dang time.

* "aww shucks", says someone in the back of the crowd. *

Not to worry though. I'm confident we can all band together to get this extremely necessarily to the survival of the human race feature added to jabba. Please thumbs-up my issue here: https://github.com/shyiko/jabba/issues/666

That's all for now. Happy coding, err' body!
0 Comments

Your comment will be posted after it is approved.


Leave a Reply.

    ​Author

    Picture
    The posts on this site are written and maintained by Jim Lynch. About Jim...
    Follow @JimLynchCodes
    Follow @JimLynchCodes

    Categories

    All
    Actionscript 3
    Angular
    AngularJS
    Automated Testing
    AWS Lambda
    Behavior Driven Development
    Blockchain
    Blogging
    Business Building
    C#
    C / C++
    ClojureScript / Clojure
    Coding
    Community Service
    CS Philosophy
    Css / Scss
    Dev Ops
    Firebase
    Fitness
    Flash
    Front End
    Functional Programming
    Git
    Go Lang
    Haskell
    Illustrations
    Investing
    Java
    Javascript
    Lean
    Life
    Linux
    Logic Pro
    Music
    Node.js
    Planning
    Productivity
    Professionalism
    Python
    React
    Redux / Ngrx
    Refactoring
    Reusable Components
    Rust
    Security
    Serverless
    Shell Scripting
    Swift
    Test Driven Development
    Things
    TypeScript
    Useful Sites
    Useful Tools
    Video
    Website Development
    WebStorm
    Writing

    Archives

    August 2021
    February 2021
    January 2021
    October 2020
    September 2020
    May 2020
    April 2020
    February 2020
    January 2020
    December 2019
    October 2019
    September 2019
    August 2019
    July 2019
    June 2019
    May 2019
    April 2019
    March 2019
    February 2019
    January 2019
    December 2018
    November 2018
    October 2018
    September 2018
    August 2018
    June 2018
    May 2018
    April 2018
    March 2018
    February 2018
    January 2018
    December 2017
    November 2017
    October 2017
    September 2017
    August 2017
    July 2017
    May 2017
    April 2017
    March 2017
    February 2017
    January 2017
    December 2016
    November 2016
    October 2016
    September 2016
    August 2016
    July 2016
    June 2016
    May 2016
    April 2016
    March 2016
    February 2016
    January 2016
    December 2015
    November 2015
    October 2015

    RSS Feed

  • Blog
  • About Jim
JimLynchCodes © 2021