简体   繁体   English

Eclipse不想运行简单的JavaFX应用程序

[英]Eclipse doesn't want to run simple JavaFX application

I have other classes named Test in other packages and one class with the same name in the default package. 我在其他软件包中有其他名为Test的类,在默认软件包中有一个具有相同名称的类。

When I click the Run button in Eclipse, instead of running this class, it runs another Test class from inside another package instead: 当我单击Eclipse中的“运行”按钮时,而不是运行此类,而是从另一个包内部运行另一个Test类:

package jfx;

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.shape.Circle;
import javafx.stage.Stage;

public class Test extends Application {
    public void start(Stage stage) {
        Circle circ = new Circle(40, 40, 30);
        Group root = new Group(circ);
        Scene scene = new Scene(root, 400, 300);

        stage.setTitle("My JavaFX Application");
        stage.setScene(scene);
        stage.show();
    }
}

How can I fix this? 我怎样才能解决这个问题?

Add a main method to allow Eclipse recognize the program as runnable application 添加一个main方法以允许Eclipse将程序识别为可运行的应用程序

public static void main(String[] args) {
    Application.launch(args);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM