public class Riwo{
static {
System.out.println("hello");
System.exit(0);
}
}
错误
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
扩展 javafx.application.Application
的类有一个异常(exception) - 您不需要为它们定义 main
方法。
The java command can be used to launch a JavaFX application by loading a class that either has a main()
method or that extends the javafx.application.Application
. In the latter case, the launcher constructs an instance of the Application class, calls its init()
method, and then calls the start(javafx.stage.Stage)
method.
否则,为了启动 Java 应用程序,必须定义 main
。
静态 block 在它们的类被加载到 JVM 中时执行。对于要加载的类,某处应该有一个触发器/启动器。