This one should be simple, but I can't figure it out myself.
I have Scala 2.9.1 installed on an Ubuntu 12.04 system.
The file is helloworld.scala
:
object HelloWorld{
def main(args:Array[String]){
println("Hello, World!")
}
}
scalac helloworld works totally fine without issue. Then scala HelloWorld gives
Exception in thread "main" java.lang.RuntimeException: Cannot figure out how to run target: HelloWorld
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:108)
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)
I've seen this question several times on forums but the poster is usually just mixing the class name and the file name so they would be trying scala helloworld, this is not what I'm doing (right?) but I get the same error.
Edit
scala -classpath ./ HelloWorld
works fine. So it's a classpath problem.