【发布时间】:2022-01-26 01:57:45
【问题描述】:
我正在尝试编写我的第一个 JavaFX 程序。这是确切的错误行: 错误:无法找到或加载主类 me.GamingCuber.CPSTest.Main 引起:java.lang.NoClassDefFoundError: javafx/application/Application 但是,我不知道这个错误是如何发生的。下面是代码:
package me.GamingCuber.CPSTest;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
public class Main extends Application {
public static void main(String[] args) {
launch(args);
}
Button button;
@Override
public void start(Stage primarystage) throws Exception{
primarystage.setTitle("Test your CPS!");
button = new Button("Click here for CPS");
StackPane layout = new StackPane();
layout.getChildren().add(button);
Scene scene = new Scene(layout, 300, 250);
primarystage.setScene(scene);
primarystage.show();
}
}
【问题讨论】:
-
也许你可以在这里找到解决方案:stackoverflow.com/questions/16868446/…
-
我将如何在 Eclipse 中执行此操作?感谢您的回复
-
好的,我想我现在可以弄清楚了。谢谢大家!
-
我尝试在我的回答中提供一个小教程。
-
请遵守 java 命名约定