Most of us have used nvm
for managing multiple versions of nodes. In java based developments, we also find the necessity of same kind of tools. Here comes 'jenv' to facilitates that.
How to install
on Mac,
brew install jenv
check whether installation is successful
jenv --version
Then install multiple version of jdk , e.g. JDK8, JDK11 or JDK17 etc.( if not already installed)
add the jdk installed path to jenv
jenv add {path-to-jdk-folder-to jdk-8}/Contents/Home
jenv add /opt/homebrew/opt/openjdk@17
To list down available jdk versions to switch between
jenv versions
To set a jdk version in the env
jenv global 17 or jenv global 8
or locally within that project
jenv local 17 or jenv local 8
Also, if there are issues.
check
- jdk path / installations
- ~/.zshrc file, whether .jenv is in the path
export PATH="$HOME/.jenv/bin:$PATH"
eval "$(jenv init -)"
- Also, rehash using
jenv rehash