SET JAVA_HOME to reflect jenv java version

add-semi-colons picture add-semi-colons · Feb 19, 2015 · Viewed 12.9k times · Source

I just started to use jenv, I followed a blog post that was explaining how to use jenv and setup multiple java version on MacOSX. But the problem now I am running into is setting up the JAVA_HOME. As I switch java environment using jenv I want to make sure JAVA_HOME on my bash_profile also changes accordingly.

How do i do that?

I have following on my ~/.bash_profile

if which jenv > /dev/null; then eval "$(jenv init -)"; fi

Answer

kimbaudi picture kimbaudi · Mar 26, 2016

Try the "export" plugin:

jenv enable-plugin export

You can check the Export plugin section in Readme.md at the jEnv Github repo (https://github.com/gcuisinier/jenv)