Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

scala - Failed to initialize compiler: object java.lang.Object in compiler mirror not found

On Ubuntu 16.04, I installed 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

With openjdk8 installed, scala fails when opening the 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.

How can I resolve it?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Using the Java 8 version of OpenJDK resolved this issue for me.

sudo update-alternatives --config java
sudo update-alternatives --config javac

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...