Suppose I have a Scala class and a Java class in a Java project and the scala class is like below
class Sam {
def main(args: Array[String]): Unit = {
pri
Typically, main methods are static
in Java, and in an object
in Scala. This allows you to run them from the command line. Your code defines a class
, not an object
.
I'd suggest changing your Scala code to:
object Sam {
def main(args: Array[String]): Unit = {
println("Hello")
}
}
You can then call this from your Java main method as follows:
class Foo {
public static void main(String[] args) {
Sam.main(args);
}
}