News

Jenv is a convenient tool for managing Java versions

What is jenv
jenv is a manager for conveniently managing Java versions on your local machine. It allows you to easily switch between different versions of Java, differentiates between the global version of Java and local versions for use in different projects, and also allows you to manage Java environment variables on the system.

jenv features
Java Version Management: jenv allows you to install and use multiple versions of Java on the same machine.

Multi-OS support: jenv can be used on macOS, Linux and Windows;

Java environment variable management: jenv can automatically set Java environment variables;

Manage JVM Settings: jenv allows you to configure JVM settings for each Java version, such as heap size, command line arguments, etc.

Application for MacOS
jenv installation
I recommend installing jenv on macOS via brew.

After installation, we register jenv in ~/.zshrc using the commands:

After running these commands, you need to make sure that ~/.zshrc contains the following lines:

You can check the installation using the command:
jenv doctor

The output could be like this:

It's okay if there are errors, the main thing is: Jenv is correctly loaded.

Installing Java
You can get a list of all available JVMs with the command:

If there are available JVMs, you can see a list of them:

If the list is empty or the required Java version is not available, you can install it like this:

# Install the current version:

# Install the required version:

After installation, you need to run a few commands that are suggested in Caveats (cautions):

Adding Java to jenv
To add Java to jenv, you need to run the following command (the path can be taken from the list of available JVMs above):
Result with confirmation of adding:

Using different versions of Java via jenv
Global version
To install the global version of java, you need to run a command similar to this one:
Which should reflect the selected version:


Local version
Before installing the required version locally, you need to go to the folder with the project. For a Flutter project, this can be the /android folder.

To install the local version, use the command with the desired Java version:

The android/.java-version file will be added with the selected version inside: 17.0. Then we check the installation of the local version using the command:

You can also check differently, just in case. Go to the folder in the android folder and call the command:

Make sure you are using the correct version:

Source: https://www.jenv.be – jenv official website.
Made on
Tilda