jenv
The jenv resource reference. This resource installs jenv, a Java version manager that allows the system to
switch between multiple versions of Java and use one as the global default. For more information on jenv,
see here. Normally, jenv will not automatically install java on your behalf unlike
nvm or pyenv. However, this resources has
additional custom functionality and will attempt to install LTS versions of Java using the openjdk@
formulas
if Homebrew is installed.
Parameters:
-
global: (string) The global version of Java to use.
-
add: (array[string]) Java install location to add. This accepts a relative or absolute path to a java home directory. Some common locations for Java installations are:
- Homebrew (aarch64):
/opt/homebrew/Cellar/
[openjdk@21]
/21.0.3/libexec/openjdk.jdk/Contents/Home
- Homebrew (Intel):
/usr/local/opt/
[openjdk@21]
/libexec/openjdk.jdk/Contents/Home
- Regular Java installs:
/Library/Java/JavaVirtualMachines/
[zulu-18.jdk]
/Contents/Home
- Note that the bolded sections represent a specific installation of Java. Replace it your version to make it work.
Additionally a integer version number can be provided for LTS versions. This resource will attempt to install the Java version directly using homebrew if it’s available using the openjdk formulas. The versions that are available for automated install are
[8, 11, 17, 21, 22]
. - Homebrew (aarch64):
Dependencies:
There is a dependency on homebrew
only if automated Java installations are needed. Otherwise, jenv
can
operate independently of homebrew.
Example usage:
Setting up Java
- Create a
codify.json
file anywhere. - Open
codify.json
with your file editor and paste in the follow configs.
- Run
codify apply
in the directory of the file. Open a new terminal and run the commandjava --version
to confirm that Java has been installed