首页 > 解决方案 > 将 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();
    }

}

标签: javamavenjavafxnetbeans

解决方案


您可以以不同的方式使用 JavaFX:文件>新建项目>Maven>JavaFX 应用程序。


推荐阅读