为什么在 jenv 中选择的 Java 版本 8 实际上不是我 Mac 上当前的 Java 版本?

huangapple go评论67阅读模式
英文:

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

问题

我已使用Homebrew安装了sbt(它又安装了Java 13),并使用brew cask安装了openjdk Java 8,操作如下:

brew install sbt
brew cask install adoptopenjdk8

然后将Java 8添加到jenv中,如下所示:

jenv add (Java 8的路径)

但仍然出现以下情况:

nicolae.marasoiu@OVO4939MB ~ % jenv versions
  system
* 1.8 (由 /Users/nicolae.marasoiu/.java-version 设置)
  1.8.0.242
  13.0
  13.0.2
  openjdk64-1.8.0.242
  openjdk64-13.0.2
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)
英文:

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)

答案1

得分: 1

已解决,使用来自 https://github.com/Homebrew/homebrew-core/issues/31390 的信息。

基本步骤如下:

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

所以缺失的部分是在 .bash_profile 或 .zprofile 中的脚本部分,允许 jenv 配置本地 shell 以了解所需的 Java 版本。

英文:

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

Basically the steps are:

brew install jenv
echo &#39;eval &quot;$(jenv init -)&quot;&#39; &gt;&gt; ~/.bash_profile
jenv add &lt;path-to-java8-home&gt;

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.

huangapple
  • 本文由 发表于 2020年4月7日 20:03:26
  • 转载请务必保留本文链接:https://go.coder-hub.com/61079616.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定