19

Every time after starting Scala 2.9.2 REPL (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0-ea) first line of code executing bring me an error:

scala> 1 + 2
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 1484)

Later during further evaluation in current REPL instance no similar errors are occured.

Has anyone any suggestion how to handle this behaviour?

thefourtheye
  • 233,700
  • 52
  • 457
  • 497
Yehor Nemov
  • 907
  • 2
  • 16
  • 31
  • 2
    I think this is because of some conflicts between Scala 2.9.2 and Java 8, try to use newer Scala or older Java – 4lex1v Sep 17 '13 at 07:10
  • 4
    Thanks for advise. Switch to Scala 2.10.2 has solved the problem. – Yehor Nemov Sep 17 '13 at 07:50
  • 1
    I am using Scala 2.11.8 -- Copyright 2002-2016, LAMP/EPFL and java version "1.8.0_111"---> Then also I am getting following errors: [INFO] No known dependencies. Compiling everything [ERROR] error: error while loading CharSequence, class file '/usr/lib/jvm/java-8-oracle/jre/lib/rt.jar(java/lang/CharSequence.class)' is broken [INFO] (class java.lang.RuntimeException/bad constant pool tag 18 at byte 10) [ERROR] one error found – Ashutosh Shukla Mar 12 '17 at 11:45

1 Answers1

26

Try to select other alternative provider java:

$ sudo update-alternatives --config java

There are some choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                            Priority   Status
------------------------------------------------------------
  0            /usr/lib/jvm/java-8-oracle/jre/bin/java          1071      auto mode
  1            /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java   1061      manual mode
  2            /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java   1051      manual mode
* 3            /usr/lib/jvm/java-8-oracle/jre/bin/java          1065      manual mode

Press enter to keep the current choice[*], or type selection number: 

EDITED: Scala is now abailable for Java 8 :-)

see http://www.scala-lang.org/news/2013/09/18/release-notes-v2.10.3-RC2.html

Chemaclass
  • 1,933
  • 19
  • 24