Using jEnv for Setting the JAVA_HOME Path

Using jEnv for Setting the JAVA_HOME Path

1 Comment

jEnv is a command line to that for Linux and OS X that makes setting the JAVA_HOME environment variable simple.

Windows users can use jEnv from a Linux subsystem.


To install jEnv on Linux or OS X will first clone the git repository to our home directory using this command:

$ git clone ~/.jenv

On Mac OS X you can also install using Homebrew with this command:

$ brew install jenv

The next step is to configure your bash profile. To  do this enter the following commands:

$ echo 'export PATH="$HOME/.jenv/bin:$PATH"' >> ~/.bash_profile

$ echo 'eval "$(jenv init -)"' >> ~/.bash_profile

If your using Zsh just change .bash_profile above to .zshrc and everything should work. You may need to logout and log back in to load changes.


Now we can use jEnv to add different versions of Java by using the following command:

$ jenv add /path/to/java/version

You can learn more about jEnv here.

About SFG Contributor

Staff writer account for Spring Framework Guru

    You May Also Like

    One comment

    1. May 27, 2020 at 8:02 am

      What is the advantage of jEnv, over ex. SDKMAN for managing the current runtime (including JAVA_HOME)?


    Leave a Reply

    Your email address will not be published. Required fields are marked *

    This site uses Akismet to reduce spam. Learn how your comment data is processed.