
IDE:IntelliJ.Trying to use JavaFX for the first time with some additional libraries, and with an installable package - (co JLinkJPackage) Have followed directions from OpenJFX for a Modular Project from IDE and can get this to work no problem.https:/openjfx.ioopenjfx-docs)。
添加库虽然我只是得到这个错误。"Error occurred during initialization of boot layerjava.lang.module.FindException.Module eu.hansolo.medusa not found, required by ModuleName"。Module eu.hansolo.medusa not found, required by ModuleName"。
阅读了许多关于这个错误的类似帖子,但在这里没有特别的乐趣。
我试过在运行配置时添加到VM中,即:--module-path${PATH_TO_FX}:modsproduction--add-modulesjavafx.controls,javafx.fxml,eu.hansolo.medusa--还是会出现以下情况 "在初始化引导层时发生错误java.lang.module.FindException.Module eu.hansolo.medusa not found 未找到模块eu.hansolo.medusa"
但是,如果我删除 "模块-info.java "文件... 如果我删除 "module-info.java "文件... 我可以在IntelliJ中运行应用程序没有问题... 然而... 我就不能使用JLink来制作自定义的运行时镜像。
任何建议或指针阅读我可以做的将是非常感激和许多感谢提前。
投票
所以问题似乎是你没有把Medusa添加到你的模块路径中。我的方法是通过使用maven来实现的。
我在pom文件中添加了依赖关系,并创建了一个module-info.java,一切似乎都正常。
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>
模块-info.java
module mavenfxied {
requires javafx.controls;
requires eu.hansolo.medusa;
exports example;
}
我做了一个例子类来测试它。
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文件添加到模块路径上的解决方案可能是唯一的办法。