gpt4 book ai didi

scala - 错误 : object tools is not a member of package scala var value: scala. tools.nsc.interpreter.IMain

转载 作者:行者123 更新时间:2023-12-02 03:49:26 24 4
gpt4 key购买 nike

我在用

  • IntelliJ IDEA 126.330
  • Scala 插件 0.7.142
  • JVM 1.6
  • Scala 2.10
  • 在 Windows 7 x64 下

决定尝试 Scala 并编写了以下应用程序

object main {
def main(args: Array[String]) {
println("Hello, world!")
}
}

然后我创建了 Scala 控制台运行配置。当我尝试运行它时,我在控制台中得到以下输出

"C:\Program Files (x86)\Java\jdk1.6.0_32\bin\java" -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:16352,suspend=y,server=n -Djline.terminal=NONE -Dfile.encoding=UTF-8 -classpath "C:\work\scala-2.10.0-RC2\lib\scala-compiler.jar;C:\work\scala-2.10.0-RC2\lib\scala-library.jar;C:\work\scala-2.10.0-RC2\lib\scala-reflect.jar;C:\Users\root\.IntelliJIdea12\config\plugins\Scala\lib\scala-plugin-runners.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA 126.330\lib\idea_rt.jar" org.jetbrains.plugins.scala.compiler.rt.ConsoleRunner -classpath "C:/Users/root/IdeaProjects/testScala/out/production/testScala;C:/work/scala-2.10.0-RC2/lib/scala-actors.jar;C:/Program Files (x86)/Java/jdk1.6.0_32/jre/lib/jce.jar;C:/Program Files (x86)/Java/jdk1.6.0_32/jre/lib/ext/localedata.jar;C:/Program Files (x86)/Java/jdk1.6.0_32/jre/lib/resources.jar;C:/Program Files (x86)/Java/jdk1.6.0_32/jre/lib/jsse.jar;C:/Program Files (x86)/Java/jdk1.6.0_32/jre/lib/ext/sunjce_provider.jar;C:/Program Files (x86)/Java/jdk1.6.0_32/jre/lib/rt.jar;C:/Program Files (x86)/Java/jdk1.6.0_32/jre/lib/charsets.jar;C:/Program Files (x86)/Java/jdk1.6.0_32/jre/lib/deploy.jar;C:/Program Files (x86)/Java/jdk1.6.0_32/jre/lib/ext/dnsns.jar;C:/Program Files (x86)/Java/jdk1.6.0_32/jre/lib/management-agent.jar;C:/Program Files (x86)/Java/jdk1.6.0_32/jre/lib/ext/sunmscapi.jar;C:/Program Files (x86)/Java/jdk1.6.0_32/jre/lib/javaws.jar;C:/work/scala-2.10.0-RC2/lib/scala-library.jar;C:/work/scala-2.10.0-RC2/lib/scala-swing.jar;C:/Program Files (x86)/Java/jdk1.6.0_32/jre/lib/plugin.jar;C:/Program Files (x86)/Java/jdk1.6.0_32/jre/lib/ext/sunpkcs11.jar;" -usejavacp2 -Y2log-classpath
Connected to the target VM, address: '127.0.0.1:16352', transport: 'socket'
Welcome to Scala version 2.10.0-RC2 (Java HotSpot(TM) Client VM, Java 1.6.0_32).
Type in expressions to have them evaluated.
Type :help for more information.

scala> <console>:5: error: object tools is not a member of package scala
var value: scala.tools.nsc.interpreter.IMain = _
^
<console>:6: error: object tools is not a member of package scala
def set(x: Any) = value = x.asInstanceOf[scala.tools.nsc.interpreter.IMain]
^

谷歌搜索后,我发现建议将 -usejavacp 参数传递给应用程序。它有助于消除错误,但应用程序未被执行。我在控制台中看到的是

"C:\Program Files (x86)\Java\jdk1.6.0_32\bin\java" -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:16383,suspend=y,server=n -Djline.terminal=NONE -Dfile.encoding=UTF-8 -classpath "C:\work\scala-2.10.0-RC2\lib\scala-compiler.jar;C:\work\scala-2.10.0-RC2\lib\scala-library.jar;C:\work\scala-2.10.0-RC2\lib\scala-reflect.jar;C:\Users\root\.IntelliJIdea12\config\plugins\Scala\lib\scala-plugin-runners.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA 126.330\lib\idea_rt.jar" org.jetbrains.plugins.scala.compiler.rt.ConsoleRunner -classpath "C:/Users/root/IdeaProjects/testScala/out/production/testScala;C:/work/scala-2.10.0-RC2/lib/scala-actors.jar;C:/Program Files (x86)/Java/jdk1.6.0_32/jre/lib/jce.jar;C:/Program Files (x86)/Java/jdk1.6.0_32/jre/lib/ext/localedata.jar;C:/Program Files (x86)/Java/jdk1.6.0_32/jre/lib/resources.jar;C:/Program Files (x86)/Java/jdk1.6.0_32/jre/lib/jsse.jar;C:/Program Files (x86)/Java/jdk1.6.0_32/jre/lib/ext/sunjce_provider.jar;C:/Program Files (x86)/Java/jdk1.6.0_32/jre/lib/rt.jar;C:/Program Files (x86)/Java/jdk1.6.0_32/jre/lib/charsets.jar;C:/Program Files (x86)/Java/jdk1.6.0_32/jre/lib/deploy.jar;C:/Program Files (x86)/Java/jdk1.6.0_32/jre/lib/ext/dnsns.jar;C:/Program Files (x86)/Java/jdk1.6.0_32/jre/lib/management-agent.jar;C:/Program Files (x86)/Java/jdk1.6.0_32/jre/lib/ext/sunmscapi.jar;C:/Program Files (x86)/Java/jdk1.6.0_32/jre/lib/javaws.jar;C:/work/scala-2.10.0-RC2/lib/scala-library.jar;C:/work/scala-2.10.0-RC2/lib/scala-swing.jar;C:/Program Files (x86)/Java/jdk1.6.0_32/jre/lib/plugin.jar;C:/Program Files (x86)/Java/jdk1.6.0_32/jre/lib/ext/sunpkcs11.jar;" -usejavacp -Y2log-classpath
Connected to the target VM, address: '127.0.0.1:16383', transport: 'socket'
Welcome to Scala version 2.10.0-RC2 (Java HotSpot(TM) Client VM, Java 1.6.0_32).
Type in expressions to have them evaluated.
Type :help for more information.

scala>

我还尝试在 IDE 选项中禁用 Scala 编译服务器。也没有帮助。

我该如何解决?

最佳答案

您应该使用Application 运行配置类型。 Scala 控制台是运行交互式控制台,而不是应用程序。

关于scala - 错误 : object tools is not a member of package scala var value: scala. tools.nsc.interpreter.IMain,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15020309/

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