简体   繁体   English

如何在 mac 上安装 openjdk 8 和 sbt 并使用默认的 openjdk 8(不是 13)?

[英]How can I install openjdk 8 and sbt on mac and have openjdk 8 (not 13) the default one?

Installing java 8 and sbt with brew and/or brew cask is clearly possible, The problem I am hitting is that brew installs java 13 as sbt dependency, Installing java 8 and sbt with brew and/or brew cask is clearly possible, The problem I am hitting is that brew installs java 13 as sbt dependency,

And I do not know a general way to go back to java 8 as default, since there are so many ways potentially to opt between java version some of which i am aware include PATH, JAVA_HOME, ln -s, java_exec selector. And I do not know a general way to go back to java 8 as default, since there are so many ways potentially to opt between java version some of which i am aware include PATH, JAVA_HOME, ln -s, java_exec selector.

Another problem potentially is that brew install sbt installs brew install java which is 13, But java 8 I install it via brew cask.另一个问题可能是 brew install sbt 安装 brew install java 是 13,但是 java 8 我通过 brew cask 安装它。

The TL is saying that Java 13 or 14 might be causing some issues eg tests fails, should I push for latest versions of OpenJdk, Scala, SBT, etc? TL 说 Java 13 或 14 可能会导致一些问题,例如测试失败,我是否应该推送最新版本的 OpenJdk、Scala、ZDD195B30217E8EC0178E7DF6BC874A5Z 等?

Have a look at a utility like Sdk Man .看看像Sdk Man这样的实用程序。

It is multi-platform and allows you to set any desired JDK as a default one.它是多平台的,允许您将任何所需的 JDK 设置为默认值。

As well as changing it to another provider/version when it will be required.以及在需要时将其更改为另一个提供程序/版本。

Indeed, SDK Man is an option.事实上,SDK Man 是一种选择。 It actually works with brew also but there need to be just a few manual steps: here they are:它实际上也可以与brew一起使用,但只需要几个手动步骤:它们是:

Installing sbt, java8, jenv & configure the shell安装 sbt、java8、jenv 并配置 shell

We used brew to install sbt (which in its turn installs java 13), and brew cask to install openjdk java 8, like this:我们使用 brew 安装 sbt (反过来安装 java 13),并使用 brew cask 安装 openjdk java 8,如下所示:

brew install sbt
brew tap AdoptOpenJDK/openjdk
brew cask install adoptjava8

We will use jenv to manage the java versions, with the information from https://github.com/Homebrew/homebrew-core/issues/31390我们将使用 jenv 管理 java 版本,信息来自https://github.com/Homebrew/homebrew-core/issues/31390

Basically the next steps are:基本上接下来的步骤是:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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