Search
  • Juan Ayala

Switching Java SDK with jEnv

In the AEM world, Oracle Java 1.8 was the de-facto standard for a long time. In recent years there has been a shift to Java 11 from both Oracle and Azul. This is what Adobe is supporting now.


Because I move from project to project, I have to change JDKs. Some times I have to work on two projects at the same time. Or I am moving between POC and client work. What I need is a version manager. Every major SDK has one.

So naturally for Java there is jEnv. In my previous post I went over how to setup a basic dev terminal. I will build upon that to include Maven & Java.


Install Java JDKs

Lets install Java 1.8 SDK from Oracle. Head over to the downloads page. Or you can download from Adobe's Software Distribution. Either way, you will need credentials to log in. Once downloaded, run the installer.


On the other hand, Azul Zulu does not have the same license restrictions. Installers are openly available. There are docker images and Homebrew formulas.


Whichever way you have installed them, you should now have two JDK's installed. To confirm it, run

Manage JAVA_HOME

You have the JDKs installed. However you need to manage the value of JAVA_HOME. You can do this with jEnv. Install it via a Homebrew formula

This only installs the executable. There are additional shell configs you must setup. This is where I rely on on Antigen to load the Oh My ZSH! plugin. Add the following lines to .zshrc

And restart your terminal. Now you need to add each JDK that was listed out by /usr/libexec/java_home -V. For example

And enable the following jEnv plugins

Now you can list the versions managed by jEnv


Install Maven

If you are using Homebrew it is simple. The Homebrew formula has a dependency on an OpenJDK. Since we are providing our own, let us going to ignore it.

And now run


Setting The Java Version

Now that you have installed the JDKs, Maven and jEnv, you are ready to start changing the Java version. There are 3 ways to do this using one of the version tokens listed with jenv versions.


Set the global version. This will be the version set by default whenever you open a shell.

Set the local version. This creates a file named .java-version in the current directory. This can be saved to source control.

Set the shell version. This only applies to the current shell instance.

Once set, you will be able to run Maven.

5 views0 comments

Recent Posts

See All