java - 将 javaFX (.jar) 文件导入 Netbeans Maven 项目
问题描述
我正在尝试将 javafx (.jar) 文件导入 Maven 项目。我已经使用 Netbeans(Java 与 Ant -> Java 应用程序)创建了一个项目,并希望在 Netbeans 中使用相同的代码(Java 与 Maven -> Java 应用程序)。使用 Ant,我可以轻松地导入和使用 (.jar) 文件,但这似乎是 Maven 的一个受阻功能。
有什么解决办法吗?
我在网上查了几篇帖子和指南,但都没有运气。
注意:在 maven 中实现 .jar 文件已得到解决。代码虽然不起作用。
当前错误:“异常运行应用程序 com.mycompany.ep_game_ref.Game 命令执行失败。”
package com.mycompany.ep_game_ref;
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.image.Image;
import javafx.stage.Stage;
public class Game extends Application
{
public static String[] args;
public static Stage primarystage;
public static ObservableList<Items.Item> items = FXCollections.observableArrayList();
public static MainCentral startGame = new MainCentral();
public static Room.Introduction intro = new Room.Introduction();
public static Settings.Difficulty SETTINGS = new Settings.Difficulty();
public static Player player = new Player();
@Override
public void start(Stage stage)
{
this.primarystage = stage;
this.primarystage.setScene(new Scenes.Welcome().setWelcomeScene());
this.primarystage.getIcons().add(new Image("images/aq_logo.png"));
this.primarystage.setResizable(false);
this.primarystage.show();
}
public static void main(String[] args) {
Application.launch();
}
}
解决方案
您可以以不同的方式使用 JavaFX:文件>新建项目>Maven>JavaFX 应用程序。
推荐阅读
- java - Calculator: I can't seem to use isPressed correctly
- java - 适用于 Kubernetes 环境的混沌测试工具 - 带有 Java 客户端
- intellij-idea - 为什么 IDEA 没有在 jar 中显示 .class 文件的源代码
- javascript - 使用快速路由器正确传递参数
- ubuntu - 为 Python 3.8.0 创建 virtualenv 会返回 Path does not exist 错误
- java - Java中微服务之间通信时如何将RestTemplate转换为String
- c# - 只更改材质实例的属性?
- python - 如何在 Matplotlib 中更改轴刻度标签率
- ios - 为什么在 ZStack 中更改图像的 contentMode 时文本会扩展?
- arduino - boot_app0.bin 和 bootloader_dio_80m.bin 文件是干什么用的?(ESP32 - Arduino IDE)