本文介绍了Scala 2.9 无法运行“hello world"Windows XP 上的示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在 Windows XP 上使用 Scala 2.9.1 final 运行 HelloWorld 示例:
I'm trying to run HelloWorld sample with scala 2.9.1 final on Windows XP:
object HelloWorld extends App {
println("Hello, World!")
}
文件保存为Hello.scala
.
当我运行 scalac Hello.scala
时,没问题.
When I run scalac Hello.scala
, it's ok.
当我运行 scala Hello
时,它写道:
When I run scala Hello
, it writes:
"Exception in thread "main" java.lang.RuntimeException: Cannot figure out how to run target"
这太荒谬了,我的 echo %PATH%
包含:
It's ridiculous, my echo %PATH%
contains:
C:\Program Files\Java\jdk1.6.0_25\bin;
C:\Program Files\Java\jdk1.6.0_25\jre\lib;
C:\Program Files\Java\jdk1.6.0_25\lib;
C:\Program Files\scala\bin
所以一切似乎都在类路径中.
so everything seems to be in classpath.
运行 scala -classpath "%PATH%;."你好
也无济于事.
请帮忙.
推荐答案
不应该是scala HelloWorld
吗?
我也可以在 Mac 上重现您的问题:
I can repro your problem on Mac too:
$ scalac hello.scala
$ scala HelloWorld
Hello, World!
$ scala Hello
Exception in thread "main" java.lang.RuntimeException: Cannot figure out how to run target: Hello
at scala.sys.package$.error(package.scala:27)
at scala.tools.nsc.GenericRunnerCommand.scala$tools$nsc$GenericRunnerCommand$$guessHowToRun(GenericRunnerCommand.scala:38)
at scala.tools.nsc.GenericRunnerCommand$$anonfun$2.apply(GenericRunnerCommand.scala:48)
at scala.tools.nsc.GenericRunnerCommand$$anonfun$2.apply(GenericRunnerCommand.scala:48)
at scala.Option.getOrElse(Option.scala:109)
at scala.tools.nsc.GenericRunnerCommand.<init>(GenericRunnerCommand.scala:48)
at scala.tools.nsc.GenericRunnerCommand.<init>(GenericRunnerCommand.scala:17)
at scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:33)
at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:89)
at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)
scala
需要类名或源名.scala Hello
不能解析为其中任何一个.
scala
expects either a class name or a source name. scala Hello
doesn't resolve to either of them.
这篇关于Scala 2.9 无法运行“hello world"Windows XP 上的示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!