DEV Community

Monirul
Monirul

Posted on

jenv - managing multiple JDK environments

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
Enter fullscreen mode Exit fullscreen mode

check whether installation is successful

 jenv --version
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode
jenv add /opt/homebrew/opt/openjdk@17
Enter fullscreen mode Exit fullscreen mode

To list down available jdk versions to switch between

jenv versions
Enter fullscreen mode Exit fullscreen mode

To set a jdk version in the env

jenv global 17 or jenv global 8 
Enter fullscreen mode Exit fullscreen mode

or locally within that project

jenv local 17 or jenv local 8
Enter fullscreen mode Exit fullscreen mode

Also, if there are issues.
check

  1. jdk path / installations
  2. ~/.zshrc file, whether .jenv is in the path
export PATH="$HOME/.jenv/bin:$PATH"
eval "$(jenv init -)"
Enter fullscreen mode Exit fullscreen mode
  1. Also, rehash using jenv rehash

Top comments (0)