[英]JavaFx in Eclipse on Mac OS
你好,我正在为学校做一个项目。 我在我的 Mac 上的 eclipse 中使用 JavaFX 时遇到问题。 在 Catalina 和现在在 Big Sur 有问题。 我将在下面发布基本代码,因为它不适用于任何东西。
我收到以下错误:
错误:无法找到或加载主 class edu.unlv.mis768.labwork12.MyFirstGUI 原因:java.lang.ClassNotFoundException:edu.unlv.mis768.labwork12.MyFirstGUI
此外,当我滚动查看 JavaFX 的导入时,它会显示:
导入javafx无法解决
当我滚动“应用程序”时,它说:
应用程序无法解析为类型
我不确定该怎么做。 我正在考虑购买一台 windows 笔记本电脑来完成这个项目。
建议或帮助将不胜感激!
下面的代码:
package edu.unlv.mis768.labwork12;
import javafx.application.*;
import javafx.scene.*;
import javafx.scene.control.*;
import javafx.stage.*;
@SuppressWarnings("restriction")
public class Basics extends Application {
@Override /* Method in Application class */
public void start(Stage primaryStage) {
int sceneWidth = 100, sceneHeight = 150;
Button button = new Button("Fear The Turtle");
Scene scene = new Scene(button, sceneWidth, sceneHeight);
primaryStage.setTitle("FX Button");
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
Application.launch(args);
}
}
Looks like there is nothing wrong except (assuming you are using Java 9 or better) maybe you need to add a module-info.java Just pop it under the src or java dir and here is the one I used to get your project going
module Labwork12 {
requires javafx.fxml;
requires javafx.controls;
requires javafx.graphics;
requires javafx.web;
requires java.logging;
requires java.desktop;
opens edu.unlv.mis768.labwork12;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.