Error while printing hello world

Hello … I am a beginner in Scala and I apologize for the question. I created a class to print “Hello World” and gave an error that I can not solve. can anybody help me?

my code:

object Teste {
def main(args: Array[String]){
print(“Hello World”)
}
}

the error:

Exception in thread “main” java.lang.NoSuchMethodError: scala.tools.nsc.interpreter.ILoop.main(Lscala/tools/nsc/Settings;)V
at org.jetbrains.plugins.scala.compiler.rt.ConsoleRunner.main(ConsoleRunner.java:64)

Process finished with exit code 1

Looks like there is something wrong with your IntelliJ Scala plugin.

1 Like

I discovered … it lacked the “extends App” … it worked now … thank you very much

my new code:

object Teste extends App{
println(“Hello World”)
}

Hi, I would recommend not using extends App, it will go away in future Scala. Use a main method instead as you were before:

object Test {
  def main(args: Array[String]): Unit = println("Hello, World!")
}
1 Like

ok…very thanks…