Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

When I click the Run button in Eclipse, instead of running this class, it runs another Test class from inside another package instead:

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?

like image 630
Monopole Magnet Avatar asked Apr 13 '15 20:04

Monopole Magnet


1 Answers

Add a main method to allow Eclipse recognize the program as runnable application

public static void main(String[] args) {
    Application.launch(args);
}
like image 183
Reimeus Avatar answered Oct 29 '22 18:10

Reimeus