[英]Drop into Scala interpreter during execution of Scala program
我試圖在我的Scala程序中插入Scala解釋器。 我已經看到了這個非常有趣的問題,但它似乎不適用於Eclipse(3.5.2 + Scala插件)。
我收到以下錯誤:
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
如果我用scalac編譯它並在我的終端上運行它,那么相同的代碼就可以工作了。 可能有什么不對? Eclipse的東西?
謝謝!
PS:這是我正在努力工作的簡化版本
import scala.tools.nsc.Interpreter._ object ScalaShell { def main(args: Array[String]) { break(Nil) } }
您沒有提到您正在使用的Scala命令行工具或Scala IDE for Eclipse的版本,但我會堅持認為命令行工具是2.8.0而Eclipse工具是2.7.x或者你在Eclipse項目類路徑上的某個地方有一個2.7.x scala-library .jar(可能是通過Maven依賴項引入的)。
如果是這種情況,那么為2.8.0.final安裝Eclipse工具應該為您解決問題。 如果沒有,那么你可能在SDT中發現了一個錯誤,你應該在這里報告。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.