【发布时间】:2016-11-30 20:52:22
【问题描述】:
在 Ubuntu 16.04 上,我安装了scala:
$ls ~/Binary/scala-2.11.8
bin doc lib man
$grep -A 2 SCALA ~/.bashrc
SCALA=~/Binary/scala-2.11.8
SBT=~/Binary/sbt
export PATH=$PATH:$SCALA/bin:$SBT/bin
安装openjdk8 后,scala 在打开 REPL 时失败:
$javac -version
javac 1.8.0_91
$
$scala
Welcome to Scala 2.11.8 (OpenJDK 64-Bit Server VM, Java 9-internal).
Type in expressions for evaluation. Or try :help.
scala>
Failed to initialize compiler: object java.lang.Object in compiler mirror not found.
** Note that as of 2.8 scala does not assume use of the java classpath.
** For the old behavior pass -usejavacp to scala, or if using a Settings
** object programmatically, settings.usejavacp.value = true.
Failed to initialize compiler: object java.lang.Object in compiler mirror not found.
** Note that as of 2.8 scala does not assume use of the java classpath.
** For the old behavior pass -usejavacp to scala, or if using a Settings
** object programmatically, settings.usejavacp.value = true.
我该如何解决?
【问题讨论】:
-
你机器的JAVA_HOME值是多少?
-
未设置。但是,我通过
sudo update-alternatives --config javac修复它以使用 openjdk-8 而不是/usr/lib/jvm/java-9-openjdk-amd64/bin/java。 -
设置 JAVA_HOME 是否消除了错误?
-
在我的机器上设置 JAVA_HOME 删除了错误
-
我遇到了同样的问题,将 java 版本更改为 8 就成功了。