March 27, 2018

Multiple JDKs

Recently I had to run a web app that I built around 5 years ago with Tomcat 6 and Java 6 in macOS High Sierra. The problem was I have Java 8 installed and used in another projects and I didn't want to change configuration files for JAVA_HOME , PATH and other stuff to point Java 6.
Thanks to this stack overflow entry, I used some tools that helped me:

  • Homebrew cask: To install mac applications
  • Jenv: To manage JDKs installed in your machine

I tried to install java7 with cask, but Oracle Java 7 is now behind a login page so no longer possible to use cask for that. I found this page where it says one can use zulu7 which is a certified OpenJDK 7 version from Azul Systems. However, I just download manually the Java 7 package from Oracle site instead.

After Java 7 installation I just added the Java 7 to Jenv:

> jenv add /Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/

I went to tomcat bin directory and set up java7 to be used:

> jenv local 1.7.0.71

then, run tomcat:

> jenv exec ./startup.sh

And done!

According to this, if the tool you can execute has a jenv plugin, you could use directly the command of the specific tool, for example mvn and jenv will intercept that and set up the JAVA_HOME before the actual mvn command is executed. That's very nice.

Additional Information

Useful commands for jenv:
jenv commands
jenv help <command>
jenv versions

This is a detailed blog with similar info. Another one.

Issue with Homebrew on Mac about creating /usr/local/Cellar.

List of Casks available to install applications. 

PID Controller for Line Tracking Robot Car

In my previous entry I described my experience assembling the Smart Robot Kit V3.0 from Elegoo . Since then, I have spent some time reading ...