Scala repl引发错误 [英] Scala repl throws error
问题描述
当我在终端上键入scala
来启动repl时,它会引发此错误
When I type scala
on the terminal to start the repl, it throws this error
scala> [init] error: error while loading AnnotatedElement,
class file '/usr/lib/jvm/java-8-oracle/jre/lib/rt.jar
(java/lang/reflect/AnnotatedElement.class)'
is broken (bad constant pool tag 15 at byte 2713)
当我按下 enter 并键入println("hello, world")
时,它将再次抛出
When I hit enter and type println("hello, world")
, it again throws this
error: error while loading CharSequence,
class file '/usr/lib/jvm/java-8-oracle/jre/lib/rt.jar
(java/lang/CharSequence.class)' is broken
(bad constant pool tag 15 at byte 1501)
我正在使用Ubuntu 14.04
和java -version
给出
java version "1.8.0_05"
Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode)
推荐答案
要么更新到新的Scala版本(2.10.3+),要么将Java降级为Java 6/7.正如您在输出中看到的那样,2.9.2在引入Java 8之前很早(Copyright 2002-2011, LAMP/EPFL
),因此它们不能很好地协同工作.
Either update to a newer scala version (2.10.3+) or downgrade java to java 6/7. As you have seen in the output, 2.9.2 was here long before java 8 was introduced (Copyright 2002-2011, LAMP/EPFL
), so they don't work well together.
这个重复的问题包含有关ubuntu的Java降级的确切说明.
This duplicate question contains exact instructions on ubuntu's java downgrade.
这篇关于Scala repl引发错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!