Get into the Scala interpreter during the execution of the Scala program

I am trying to switch to the Scala interpreter in the middle of my Scala program. I saw this very interesting question , but it doesn't seem to work in the Eclipse plugin (3.5.2 + Scala).

I get the following error:

Exception in thread "main" java.lang.NoClassDefFoundError: scala/io/LowPriorityCodecImplicits at scala.tools.nsc.Interpreter$.breakIf(Interpreter.scala:1265) at userInterface.CommandInterpreter$$anonfun$main$1.apply$mcVI$sp(CommandInterpreter.scala:102) at scala.collection.immutable.Range$ByOne$class.foreach$mVc$sp(Range.scala:275) at scala.collection.immutable.Range$$anon$1.foreach$mVc$sp(Range.scala:267) at userInterface.CommandInterpreter$.main(CommandInterpreter.scala:101) at userInterface.CommandInterpreter.main(CommandInterpreter.scala) Caused by: java.lang.ClassNotFoundException: scala.io.LowPriorityCodecImplicits at java.net.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:248) ... 6 more 

The same code works if I compile it using scalac and run it on my terminal. What could be wrong? Something with Eclipse?

Thanks!

PS: here is a simplified version of what I'm trying to do

  import scala.tools.nsc.Interpreter._
 object ScalaShell {
   def main (args: Array [String]) {
     break (nil)
   }
 }
+4
source share
1 answer

You did not mention the versions of the Scala command line tools or the Scala IDE for Eclipse that you use, but I will stand my neck and guess that the command line tools are 2.8.0 while the Eclipse tool is 2.7.x or you have 2.7.x scala -library.jar somewhere in your path to the Eclipse classes (maybe pulled through a Maven dependency).

If this is the case, then the initial installation of the Eclipse tool for 2.8.0.final should solve the problem for you. If this is not the case, you probably found an error in the SDT, and you should report it here .

+1
source

All Articles