java - 错误:错误:无法找到或加载主类 neon.Main
问题描述
我正在编写一个应用程序,但我收到标题中命名的错误消息。在 src 文件夹中是软件包 neon 下的 Main.java 类。包 neon.friends 包含 Friends.fxml。并且包 neon.views 包含 MainItemsController.java、MainItems.fxml 和 MainView.fxml。
下面是主类的代码:
package neon;
import java.io.IOException;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
public class Main extends Application {
private Stage primaryStage;
private static BorderPane mainLayout;
@Override
public void start(Stage primaryStage) throws IOException {
this.primaryStage = primaryStage;
this.primaryStage.setTitle("Neon");
showMainView();
showMainItems();
}
private void showMainView() throws IOException{
FXMLLoader loader = new FXMLLoader();
loader.setLocation(Main.class.getResource("view/MainView.fxml"));
mainLayout = loader.load();
Scene scene = new Scene(mainLayout);
primaryStage.setScene(scene);
primaryStage.show();
}
private void showMainItems() throws IOException{
FXMLLoader loader = new FXMLLoader();
loader.setLocation(Main.class.getResource("view/MainItems.fxml"));
BorderPane mainItems = loader.load();
mainLayout.setCenter(mainItems);
}
public static void showFriends() throws IOException{
FXMLLoader loader = new FXMLLoader();
loader.setLocation(Main.class.getResource("friends/Friends.fxml"));
BorderPane friends = loader.load();
mainLayout.setCenter(friends);
}
public static void main(String[] args) {
launch(args);
}
}
解决方案
推荐阅读
- node.js - 如何修复 SyntaxError: Unexpected token ... 在我的本地机器上使用 socket.io
- google-app-engine - Google App Engine 的文件缓存有哪些选项?
- wordpress - 覆盖 woocommerce 添加购物车链接
- python - 由于令牌问题,在 Heroku 上托管 Discord.py 机器人失败
- javascript - 如何访问嵌套的 JSON 数据
- javascript - 我需要使用 JSON 对象从数组创建图像库
- javascript - 弹出窗口打开和关闭时正确执行脚本
- python - 如何在 Python 中使用 OpenCV 检测银行收据中的列并将图像拆分为单独的文件?
- javascript - 我正在创建 2 个状态 svg 驱动的动画图标,但出现错误
- node.js - 从运行 express-graphql 的节点服务器将 GraphQLUpload 发送到 imagekit.io