我正在使用
决定尝试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]
^
在Google上搜索后,我发现了将-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编译服务器。也没有帮助。
我该如何解决?
答案 0 :(得分:1)
您应该使用应用程序运行配置类型。 Scala控制台是运行交互式控制台,而不是应用程序。
答案 1 :(得分:0)