Monopole Magnet
Monopole Magnet

Reputation: 435

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?

Upvotes: 5

Views: 2335

Answers (1)

Reimeus
Reimeus

Reputation: 159754

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

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

Upvotes: 5

Related Questions