我剛剛做了一個干凈的安裝。jdk 8(來自采用.net)和 sbt(使用自制軟體)在新映像的 macbook 上。無論如何,自制軟體還是使用了 java 18,而 sbt 不起作用。
我按照這里的說明操作: https ://www.scala-sbt.org/1.x/docs/Installing-sbt-on-Mac.html
通過該頁面上的鏈接到采用.net,我找到了唯一適用于 mac os 的 jdk 8。
$ java -version
openjdk version "1.8.0_322"
OpenJDK Runtime Environment (Temurin)(build 1.8.0_322-b06)
OpenJDK 64-Bit Server VM (Temurin)(build 25.322-b06, mixed mode)
按照 sbt 頁面上的說明,我使用了自制軟體...
$ brew install sbt
當我檢查版本時,我發現了一個問題......
$ sbt about
[info] welcome to sbt 1.6.2 (Homebrew Java 18)
[info] loading project definition from /Users/KHinson1/project
[info] set current project to khinson1 (in build file:/Users/KHinson1/)
[info] This is sbt 1.6.2
[info] The current project is ProjectRef(uri("file:/Users/KHinson1/"), "khinson1") 0.1.0-SNAPSHOT
[info] The current project is built against Scala 2.12.15
Homebrew 使用 java 18 安裝它?!如何清理它并使用我安裝的 java 8?我在筆記本電腦上找不到 java 18。
我立即遇到了試圖用sbt assembly
...編譯一個胖罐子的問題
java.lang.UnsupportedOperationException: The Security Manager is deprecated and will be removed in a future release
at java.base/java.lang.System.setSecurityManager(System.java:416)
at sbt.TrapExit$.installManager(TrapExit.scala:52)
at sbt.StandardMain$.runManaged(Main.scala:52)
at sbt.xMain.run(Main.scala:28)
at xsbt.boot.Launch$.$anonfun$run$1(Launch.scala:149)
at xsbt.boot.Launch$.withContextLoader(Launch.scala:176)
at xsbt.boot.Launch$.run(Launch.scala:149)
at xsbt.boot.Launch$.$anonfun$apply$1(Launch.scala:44)
at xsbt.boot.Launch$.launch(Launch.scala:159)
at xsbt.boot.Launch$.apply(Launch.scala:44)
at xsbt.boot.Launch$.apply(Launch.scala:21)
at xsbt.boot.Boot$.runImpl(Boot.scala:78)
at xsbt.boot.Boot$.run(Boot.scala:73)
at xsbt.boot.Boot$.main(Boot.scala:21)
at xsbt.boot.Boot.main(Boot.scala)
[error] [launcher] error during sbt launcher: java.lang.UnsupportedOperationException: The Security Manager is deprecated and will be removed in a future release
我知道這是一個 java 17 的問題,來自這樣的問題......
sbt 程式集無法創建 jar 獲取 java.lang.UnsupportedOperationException
我過去使用自制軟體來安裝 sbt,但老實說,我對 mac 很陌生,當我沒有安裝 java 18 時,我不明白它是如何使用 java 18 的。
如何讓 java 18 完全脫離我的機器(我什至找不到它)并按預期使用 java 8 安裝 sbt?
謝謝。
編輯
我嘗試過使用 jenv,如下所述: 如何在 mac 上安裝 openjdk 8 和 sbt 并使用默認的 openjdk 8(不是 13)?
我把它指向我安裝的openjdk
$ which java
/usr/bin/java
但是當我嘗試
$ jenv add /usr/bin/java
/usr/bin/java is not a valid path to java installation
(編輯我現在已經把所有東西都吹了出來嘗試SDKMAN,但我想知道我是否應該/Library/Java/JavaVirtualMachines/temurin_???
直接指出?)
我嘗試使用brew install [email protected]
which lists jdk 8 作為其依賴項,但它只是不起作用(“找不到命令”)。我想要一個更新的 sbt,但我認為sbt.version=1.3.6
在 build.properties 中指定類似的東西會迫使 sbt 稍后升級。
我嘗試按照 sbt 安裝頁面上的建議“擴展 zip”,但同樣的事情(“找不到命令”),現在不管我將它擴展到哪里或如何更新路徑。
編輯 2
我愿意嘗試 sdkman,但此時我已經嘗試安裝/卸載一些東西,但我不知道如何從我的機器上洗掉 java,我擔心會因為太多而搞砸競爭的嘗試。
uj5u.com熱心網友回復:
據我所知,您可以在 brew 中安裝特定的 java 版本。使用brew cask install java8
(當然你需要先安裝木桶,brew install cask
)。
uj5u.com熱心網友回復:
我正在使用java 11,jenv,剛剛做了brew install sbt
,我這邊沒有問題。
$ java --version
openjdk 11.0.11 2021-04-20
OpenJDK Runtime Environment AdoptOpenJDK-11.0.11 9 (build 11.0.11 9)
OpenJDK 64-Bit Server VM AdoptOpenJDK-11.0.11 9 (build 11.0.11 9, mixed mode)
$ brew reinstall sbt
...
==> Reinstalling sbt
==> Pouring sbt--1.6.2.all.bottle.tar.gz
==> Caveats
You can use $SBT_OPTS to pass additional JVM options to sbt.
Project specific options should be placed in .sbtopts in the root of your project.
Global settings should be placed in /opt/homebrew/etc/sbtopts
Homebrew's installation does not include `sbtn`.
==> Summary
?? /opt/homebrew/Cellar/sbt/1.6.2: 8 files, 3.7MB
$ sbt about
[info] Updated file /Users/rui/Downloads/sbt-test/project/build.properties: set sbt.version to 1.6.2
[info] welcome to sbt 1.6.2 (AdoptOpenJDK Java 11.0.11)
[info] loading project definition from /Users/rui/Downloads/sbt-test/project
[info] set current project to sbt-test (in build file:/Users/rui/Downloads/sbt-test/)
[info] This is sbt 1.6.2
[info] The current project is ProjectRef(uri("file:/Users/rui/Downloads/sbt-test/"), "sbt-test") 0.1.0-SNAPSHOT
[info] The current project is built against Scala 2.12.15
[info] Available Plugins
[info] - sbt.ScriptedPlugin
[info] - sbt.plugins.CorePlugin
[info] - sbt.plugins.Giter8TemplatePlugin
[info] - sbt.plugins.IvyPlugin
[info] - sbt.plugins.JUnitXmlReportPlugin
[info] - sbt.plugins.JvmPlugin
[info] - sbt.plugins.MiniDependencyTreePlugin
[info] - sbt.plugins.SbtPlugin
[info] - sbt.plugins.SemanticdbPlugin
[info] sbt, sbt plugins, and build definitions are using Scala 2.12.15
我會建議兩件事進行故障排除:
- 結帳
PATH
的東西 - 跑
brew doctor
uj5u.com熱心網友回復:
@Ivan Stanislavciuc 的 SDKMAN 推薦非常棒。它如何管理 Java 環境真的很容易。
這是我擺脫錯誤開始并讓事情正常進行的程序。
# uninstall everything
brew uninstall sbt
brew uninstall jenv
cd /Library/Java/JavaVirtualMachines
sudo rm -rf <java installation>
# install sdkman
curl -s "https://get.sdkman.io" | bash
# select java version
# (I chose temurin jdk 8 which is formerly openj9;
# can't find hotspot AdoptOpenJdk anymore, is it gone?)
sdk list java
sdk install java 8.0.322-tem
sdk default java 8.0.322-tem
# install sbt
sdk install sbt
就這么簡單。
我曾經使用熱點采用開放 jdk ......但我現在沒有看到那個可用的地方。我看到熱點仍然是 SDKMAN 說明中 sbt 安裝頁面上的推薦(.hs-adpt
“熱點采用開放 jdk”嗎?)。但是 temurin 是我認為的 openj9,它也與 sbt 頁面上的采用.net 鏈接相匹配,所以現在我認為沒關系。
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/459742.html
上一篇:動態Akka流接收器