score:7

Accepted answer

your main must take an array of string. it currently takes a single string

from scala's official website :

object helloworld {
  def main(args: array[string]): unit = {
    println("hello, world!")
  }
}

https://www.scala-lang.org/documentation/getting-started.html

also, make sure you are using the "run as scala application" option in eclipse.

score:0

in my case i had both a companion object and a class with the same name, which is normally okay in scala but appears to have confused java.

renaming either the object or class to a different name solved the problem.

score:1

this may not help each and everyone, but i did face the same issue, i cleaned the project and it worked!!!

score:1

in my case (intellij ultimate 2018.1), i had a test with the same name than the object with the main method:

  • src/main/scala/com/xx/xx/myapp
  • src/test/scala/com/xx/xx/myapp

when tried to dun main...myapp failed with the exception in this question.

just renamed src/test/scala/com/xx/xx/myapp to myapptest

score:2

you have a class with tha same name in tests.

check that your test folder does not contain object hello. check yuor test package for unique object names. after renaming, problem must be solved.

there is no difference how to implement main method. you can do like this:

object hello {
  def main(args: string) = {
    println("hello world!");
 }
}

or like this:

object hello extends app {
    println("hello world!");
 }

```


Related Query

More Query from same tag