gpt4 book ai didi

eclipse - 在 Scala 程序执行期间进入 Scala 解释器

转载 作者:行者123 更新时间:2023-12-01 05:44:10 25 4
gpt4 key购买 nike

我试图在我的 Scala 程序中间插入 Scala 解释器。
我见过this very interesting question但它似乎不适用于 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:这是我正在尝试制作的简化版本
导入 scala.tools.nsc.Interpreter._
对象 ScalaShell {
def main(args: Array[String]) {
中断(无)
}
}

最佳答案

你没有提到你正在使用的 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 中发现了一个错误,您应该报告它 here .

关于eclipse - 在 Scala 程序执行期间进入 Scala 解释器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3373783/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com