简体   繁体   中英

Why the java version 8 which is selected in jenv is not in fact the current java on my Mac?

I have used brew to install sbt (which in its turn installs java 13), and brew cask to install openjdk java 8, like this:

brew install sbt
brew cask install adoptjava8

Then added the java 8 to jenv as seen below:

jenv add (path to java 8 Home)

nicolae.marasoiu@OVO4939MB ~ % jenv versions
  system
* 1.8 (set by /Users/nicolae.marasoiu/.java-version)
  1.8.0.242
  13.0
  13.0.2
  openjdk64-1.8.0.242
  openjdk64-13.0.2

But still:

nicolae.marasoiu@OVO4939MB ~ % java -version
openjdk version "13.0.2" 2020-01-14
OpenJDK Runtime Environment (build 13.0.2+8)
OpenJDK 64-Bit Server VM (build 13.0.2+8, mixed mode, sharing)

Solved it, with the information from https://github.com/Homebrew/homebrew-core/issues/31390

Basically the steps are:

brew install jenv
echo 'eval "$(jenv init -)"' >> ~/.bash_profile
jenv add <path-to-java8-home>

So the missing part was the scripting part in.bash_profile or.zprofile that allows for jenv to configure the local shell to know about the wanted java version.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM