score:5
Accepted answer
The main function needs to be inside an object, not a class definition. So instead of this
package main_function_test
class exm {
def main(args: Array[String]): Unit = {
println("Hello world")
}
}
write this:
package main_function_test
object exm {
def main(args: Array[String]): Unit = {
println("Hello world")
}
}
Source: stackoverflow.com
Related Query
- Error in running Scala Program: Main method not found in class main, please define the main method
- Spark Scala Error - Error: Main method not found in class
- Scala IDE Error: Main method not found in class 'hello'
- main class not found in spark scala program
- Error when running Scala project - class scala.deprecatedInheritance in compiler mirror not found
- Main class not found error while creating Maven Project in Scala IDE
- Error running scala console. Module not found
- Scala IDE Error -could not find/load main class
- Scala Main Class not found in Eclipse ide
- class not found error - scala
- Scala: Main method not found in class
- Why Scala reports error if does not specify this.type when using chain method in inherited class
- Getting an error in intellij referencing a scala method I'm not actually using in a class I have used
- Class Not Found running Scala in IntelliJ SBT project
- Error when building Scala Maven project: Could not find or load main class scala_maven_executions.MainWithArgsInFile
- scala Ide Not identifying my class as main method
- Running tests on Intellij: Class not found
- Could not find or load main class in scala in intellij IDE
- reduceByKey method not being found in Scala Spark
- Why am I getting this error when running Scala 2.13 tests in IntelliJ, but not with Scala 2.12?
- Scala Error: Could not find or load main class in both Scala IDE and Eclipse
- How to call main method of a Scala program from the main method of a java program?
- object scala in compiler mirror not found - running Scala compiler programmatically
- In Scala static value initialization does not appear to be happening before the main method is called
- protected method that takes an abstract super class instance and the "access to protected method not permitted" error
- Error on scala class : recursive method printExpr needs result type
- Scala deserialization: class not found
- Spark Scala getting class not found scala.Any
- Main method is not called in Scala script
- Compiler Error : com.sun.tools.javac.code.Symbol$CompletionFailure: class file for akka.actor.SupervisorStrategy$1 not found
More Query from same tag
- When overloading `apply` method: Slick error message 'value tupled is not a member of object'
- Shadow any2stringadd when implicitly converting Symbol
- Transpose dataframe withe many columns
- Adding standard Java libraries with SBT
- Converting String RDD to Int RDD
- Get Full Stack Trace in Spark Log
- Linearly reading a multi-dimensional array obeying dimensional sub-sectioning
- Kleisli in Cats for Scala example not working
- How to handle an ADT (sealed trait) with ZIO config
- Mock a method from implicit class in specs2
- MiMa complains about loss of a synthetic method, even though I put the original line back in place
- What's the type of a class inside an object inside a trait
- How to define methods to deal with Datasets with parametrized types?
- Scala StackOverflowError while Java can handle it
- Json serialization of complex list
- Scala: Delete Directory Recursively not working
- Having trouble creating Scala delegate for java.util.Collection#toArray
- Regex unapply in for comprehension with if guard not compiling
- Scala Regex enable Multiline option
- Cloning an instance of a class, but not exactly
- scala.collection.immutable.$colon$colon cannot be cast to java.lang.String
- Scala/Akka/ReactiveMongo: process does not terminate after system.shutdown()
- Create a new dataframe (with different schema) from selected information from another dataframe
- How to synchronize insert/removal of elements to/from a data structure, the Functional Way?
- How to create a map out of two lists?
- Processing an akka stream asynchronously and writing to a file sink
- What's the difference between A<:B and +B in Scala?
- How to measure the running time of a scala scalding program?
- What is Scala for: getline(), std::cin.eof(), std::cin.bad()?
- Compile error scala project