If you set up a Scala HelloWorld example naively, it is easy to get the following perplexing error message:
:runError: Main method is not static in class com.garysieling.HelloWorld, please define the main method as: public static void main(String[] args)
This happens if the code looks like the following:
package com.garysieling {
class HelloWorld extends App {
System.out.println("test")
}
In fact, “HelloWorld” must be set as an object, as there are no statics with classes in scala.
package com.garysieling {
import scala.App
object HelloWorld extends App {
System.out.println("test")
}
}
THANK YOU!!!!!!!
yep that was it! 🙂
Omg thanks, that was so obvious but I didn’t think of it xD
+1
Is it possible to use a Main class and also use Dependency Injection? I’m building a small app and I want to inject services, appConfigs etc.
Thank you in advance for your help 🙂