IntelliJ IDEA 10.5 (probably this matters).
I am new to Scala, so I started in an akward way. I created one file with two classes -- empty MainApp and another class, HelloWorld with method main.
I compiled it and executed -- IntelliJ automatically detected HelloWorld as main class. It was OK.
Then, I moved main method to MainApp, and deleted (then empty) HelloWorld class. When I tried to run it, IntelliJ sticked to HelloWorld nevertheless. So I reconfigured project and selected MainApp as main class.
I tried to run it with such result:
MainApp main method should be static
I am completely puzzled. First of all, Scala does not have static methods. Second of all, why it does not compile now, when it compiled before (with HelloWorld class). I though that only requirement is having one main method.
Thank you in advance for your help.
Please note: I know I can start a new project from scratch to avoid the problem altogether, but I would like to learn something, i.e. get to know what is going on, and fixing this project.
static methods in Java roughly correspond to singleton methods in Scala. You should have
object MainApp {
def main(args : Array[String]) = ...
}
in your code, not class MainApp
.
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