public class Riwo{
static {
System.out.println("hello");
System.exit(0);
}
}
Err
or: Main method not found in class saky.Riwo, please define the main method as:
public static void main(String[] args)
or a JavaFX application class must extend javafx.application.Application
There is an exception for classes that extend javafx.application.Application - you don't need to define the main method for them.
The java command can be used to launch a JavaFX application by loading a class that either has a
main()method or that extends thejavafx.application.Application. In the latter case, the launcher constructs an instance of the Application class, calls itsinit()method, and then calls thestart(javafx.stage.Stage)method.
Otherwise, in order to start a Java application, the main has to be defined.
Static blocks are executed when their class is being loaded into the JVM. For a class to be loaded, there should be a trigger/launcher somewhere.
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