DEV Community

Gowtham Srinivasan
Gowtham Srinivasan

Posted on

How to install JEnv using command prompt

For Windows/Linux/Mac Users

1) Open Command prompt in your system

2) In Command prompt, first install the Home brew by entering the below command

$/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

3) Now, Install the JEnv by entering the below command

Installation of JEnv

Enter the following code for installing JEnv

Linux / OS X

$ git clone https://github.com/jenv/jenv.git ~/.jenv
Enter fullscreen mode Exit fullscreen mode

Mac OS X via Homebrew

$ brew install jenv
Enter fullscreen mode Exit fullscreen mode

4) Install either Bash or Zsh by entering the following code in command prompt

Bash

$ echo 'export PATH="$HOME/.jenv/bin:$PATH"' >> ~/.bash_profile
$ echo 'eval "$(jenv init -)"' >> ~/.bash_profile
Enter fullscreen mode Exit fullscreen mode

Zsh

$ echo 'export PATH="$HOME/.jenv/bin:$PATH"' >> ~/.zshrc
$ echo 'eval "$(jenv init -)"' >> ~/.zshrc
Enter fullscreen mode Exit fullscreen mode

5) Configure the following command in command prompt to add the Jenv file

$ jenv add /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
  oracle64-1.6.0.39 added
$ jenv add /Library/Java/JavaVirtualMachines/jdk17011.jdk/Contents/Home
  oracle64-1.7.0.11 added

for Mac Users

/usr/libexec/java_home/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Enter fullscreen mode Exit fullscreen mode

Note: In above code, change the version according to the Installed Java version

6) To check the Installed Java version in your system enter the following code in command prompt:

$ java -version

Top comments (0)