这是什么意思:JavaFX 应用程序类必须扩展 javafx.application.Application?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/40927950/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What does it mean: JavaFX application class must extend javafx.application.Application?
提问by Mukesh Patel
What is meant by this error:
这个错误是什么意思:
Error: Main method not found in class Static.A, please define the main method as: public static void main(String[] args) or a JavaFX application class must extend javafx.application.Application
错误:在类 Static.A 中找不到 Main 方法,请将主要方法定义为:public static void main(String[] args) 或 JavaFX 应用程序类必须扩展 javafx.application.Application
I was trying to run a program Without main Method..
我试图在没有主方法的情况下运行程序..
public class A
{
static
{
System.out.println("Hello");
System.exit(0);
}
}
回答by XtremeBaumer
this means you don't have a main method in your class as the error says. replace the static
with public static void main(String[] args)
and it works. also it is not possible to run a program without main method
这意味着您的类中没有 main 方法,如错误所述。替换为static
,public static void main(String[] args)
它可以工作。也无法在没有 main 方法的情况下运行程序
回答by Thusitha Thilina Dayaratne
If you want to run your program either you should have the main
method or if it is a JavaFX application then you have to have the start
method.
According to your class, you don't have neither of the conditions. So that is why you get the error
如果您想运行您的程序,要么您应该拥有该main
方法,要么它是一个 JavaFX 应用程序,那么您必须拥有该start
方法。根据你的班级,你不具备这两个条件。所以这就是你得到错误的原因