我有一个愚蠢的问题,因为我在这里搜索了数据库,但找不到答案。我是 javaFX 的新手,所以......请帮帮我!
这是我使用的代码。虽然这是一个示例代码。
package helloworld;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
public class HelloWorld extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("Hello World!");
Button btn = new Button();
btn.setText("Say 'Hello World'");
btn.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
System.out.println("Hello World!");
}
});
StackPane root = new StackPane();
root.getChildren().add(btn);
primaryStage.setScene(new Scene(root, 300, 250));
primaryStage.show();
}
}
使用 .\helloworld 从目录中编译后javac HelloWorld.java
,我运行以下命令:
PS D:\documents\javafx\helloworld> javafxpackager -createjar -appclass HelloWorld -srcdir . -outdir out -outfile hello.jar -v
但是,当我跑步时,cd
我得到了这个:out
java -jar hello.jar
PS D:\documents\javafx\helloworld\out> java -jar hello.jar
Error: Could not find or load main class HelloWorld
发生了什么或者我做错了什么?
任何建议/解释都非常感谢。
谢谢大家。
泽斯托斯。