我正在使用
- IntelliJ IDEA 126.330
- Scala 插件 0.7.142
- JVM 1.6
- 斯卡拉 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 编译服务器。也没有帮助。
我如何解决它 ?