[英]Error: "missing JavaFX application class" when starting from Eclipse
我使用 JavaFX 並嘗試運行我的代碼,但出現“缺少 JavaFX 應用程序類”錯誤。 我為 javafx.controlls 和 javafx.fxml 添加了 JVM 參數。 我還使用另一個名為“dyn4j”的庫,但我認為這不是錯誤的觸發因素。
這是我的代碼的樣子:
public class DropToTheBottom extends Application {
private Pane pane;
private World<MyPhysicsBody> world;
private Scene scene;
@Override
public void start(Stage primaryStage) throws Exception {
Group root = new Group();
root.getChildren().add(pane);
scene = new Scene(root, Settings.SCENE_WIDTH, Settings.SCENE_HEIGHT);
primaryStage.setScene(scene);
primaryStage.show();
pane.getTransforms().add(new Translate(Settings.SCENE_WIDTH / 2, Settings.SCENE_HEIGHT));
pane.getTransforms().add(new Scale(Settings.SCALE, -Settings.SCALE));
world = new World<>();
world.setGravity(World.EARTH_GRAVITY);
Controller controller = new Controller(pane, world);
// creates a floor on the bottom of the screen
world.addBody(controller.createRectangle(new Vector2(1, 0), scene.getWidth(), 1, Color.RED, MassType.INFINITE));
// create rectangle bodies and add them to the world
for (int i = 0; i < 2; i++) {
world.addBody(
controller.createRectangle(new Vector2(0, 10), 1, 1, Color.BLUE, MassType.NORMAL, 0.8, 1.2, 0.5));
}
world.addBody(controller.createCircle(0, 5, 0.5, 1, 1, 0.5, MassType.NORMAL, Color.RED, false));
world.addBody(controller.createCircle(2, 5, 0.5, 1, 1, 0.5, MassType.NORMAL, Color.BLUE, true));
controller.startAnimation();
}
public static void main(String[] args) {
launch(args);
}
}
我希望任何人都可以幫助我解決這個問題。
我自己解決了我的問題。 我使用新的 Java 文件創建了一個新項目,但名稱相同,並且僅將代碼復制到新的 Java 文件中。 我不知道為什么這解決了我的問題,但確實如此。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.