I've just been playing with Scala, and installed the Eclipse plugin as described at http://www.scala-lang.org/node/94, but after entering the "Hello World" test example and setting up the run configuration as described, I get the following error
Exception in thread "main" java.lang.NoSuchMethodError: main
For reference the code is
package hello
object HelloWorld extends Application {
println("Hello World!")
}
I've tinkered a bit with the obvious solutions (adding a main method, adding a singleton object with a main method) but I'm clearly doing something wrong.
Can anyone get their test example to work, or point out what I am doing wrong?
I hit the same issue last night. I fixed it by a) removing any existing scala run configurations and then by (I'm not kidding) adding a linebreak before the first curly brace.
Another thing I did that works is to go into the existing run configuration and add some junk into the "arguments" tab. I'm ignoring the arguments anyway, so it didn't affect the output of the program, but it got the plugin to find main again
I also hit this error with the below code:
package hello
class HelloWorld extends Application {
Console.println("Hello World!")
}
The error was using class
instead of object
, when I switched to object
it ran fine in Eclipse.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With