JavaFX,JLink/JPackage Module问题-添加库“启动层java.lang.module.FindException初始化期间发生错误". [英] JavaFX, JLink/JPackage Module issue - adding Libraries "Error occurred during initialization of boot layer java.lang.module.FindException"

查看:149
本文介绍了JavaFX,JLink/JPackage Module问题-添加库“启动层java.lang.module.FindException初始化期间发生错误".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

IDE:IntelliJ.首次尝试将JavaFX与一些其他库以及可安装的软件包一起使用-(c/o JLink/JPackage)遵循OpenJFX针对IDE的模块化项目的指示,可以使它正常工作. https://openjfx.io/openjfx-docs/

IDE: IntelliJ. Trying to use JavaFX for the first time with some additional libraries, and with an installable package - (c/o JLink/JPackage) Have followed directions from OpenJFX for a Modular Project from IDE and can get this to work no problem. https://openjfx.io/openjfx-docs/

添加库,尽管出现此错误:启动层初始化期间发生错误java.lang.module.FindException:未找到模块eu.hansolo.medusa,由ModuleName要求

Adding libraries though I am just getting this error: "Error occurred during initialization of boot layer java.lang.module.FindException: Module eu.hansolo.medusa not found, required by ModuleName"

已针对此错误读取了多个类似的线程,但在这里没有特别的乐趣.

Have read a number of similar threads on this error but no joy here specifically.

尝试在运行配置中向VM添加添加,即:
--module-path$ {PATH_TO_FX}:模组/制作--add-modulesjavafx.controls,javafx.fxml,eu.hansolo.medusa-
仍在获取启动层初始化期间发生错误java.lang.module.FindException:找不到模块eu.hansolo.medusa"

Have tried adding adding to VM on run configuration ie:
--module-path ${PATH_TO_FX}:mods/production --add-modules javafx.controls,javafx.fxml,eu.hansolo.medusa -
still getting "Error occurred during initialization of boot layer java.lang.module.FindException: Module eu.hansolo.medusa not found"

但是..如果删除"module-info.java"文件.我可以在IntelliJ中运行该应用程序...但是,那么我将无法使用JLink进行创建.自定义运行时映像.

However.. If I delete the "module-info.java" file.. I can run the application in IntelliJ no problem.. however.. I then can't use JLink to make the custom runtime image.

我会尽力提供任何建议或阅读建议,并在此先致以谢意.

Any advice or pointers to reading I can do would be greatly appreciated and many thanks in advance.

推荐答案

所以问题似乎是您尚未将Medusa添加到模块路径中.我完成此操作的方法是使用Maven.

So the issue appears to be that you haven't added Medusa to your module path. The way I accomplished this is by using maven.

我将依赖项添加到了pom文件中,并创建了一个模块info.java,一切似乎都可以正常工作.

I added the dependencies to my pom file and created a module-info.java and everything seemed to work.

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <properties>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
    </properties>
    <groupId>org.example</groupId>
    <artifactId>MavenFxied</artifactId>
    <version>1.0-SNAPSHOT</version>
    <dependencies>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-controls</artifactId>
            <version>14.0.1</version>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-graphics</artifactId>
            <version>14.0.1</version>
        </dependency>
        <dependency>
            <groupId>eu.hansolo</groupId>
            <artifactId>Medusa</artifactId>
            <version>11.5</version>
        </dependency>
    </dependencies>

</project>

module-info.java

module mavenfxied {
    requires javafx.controls;
    requires eu.hansolo.medusa;
    exports example;
}

我制作了一个示例类来对其进行测试.

I made an example class to test it out.

Main.java

package example;

import eu.hansolo.medusa.Gauge;
import eu.hansolo.medusa.GaugeBuilder;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

public class Main extends Application {

    public void start(Stage stage) throws Exception {
        StackPane pane = new StackPane();
        Gauge g = GaugeBuilder.create()
                .skinType(Gauge.SkinType.SPACE_X)
                .animated(true)
                .decimals(0)
                .title("SpaceX")
                .unit("km/h")
                .maxValue(30000)
                .threshold(25000)
                .build();
        pane.getChildren().add(g);
        Scene scene = new Scene(pane);
        stage.setScene(scene);
        stage.show();
    }
}

如果您不使用maven,那么将jar文件添加到模块路径上某个位置的注释中提出的解决方案可能是唯一的方法.

If you aren't using maven, then the solution proposed in the comments of adding the jar file to a location on the module-path might be the only way.

这篇关于JavaFX,JLink/JPackage Module问题-添加库“启动层java.lang.module.FindException初始化期间发生错误".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆