java - 模块化项目使用 jOpenDocument 引发 InvalidModuleDescriptorException

标签 java java-module module-info jopendocument

我正在 Eclipse 2019-06 中使用 java/javafx 12 开发一个模块化 java 项目,使用混合模块化和非模块化方法。由于运行时异常,无法使程序运行。

我需要使用混合模块化和非模块化方法,因为该程序需要外部库。它们中的大多数都作为模块提供,但 jOpenDocument 并未由开发人员作为模块提供。

除了“自动模块 jOpenDocument 的名称不稳定”之外,我没有收到 Eclipse 的任何提示,这不应该是问题所在。

当我启动程序时,出现以下异常:

Error occurred during initialization of boot layer
java.lang.module.FindException: Unable to derive module descriptor for C:\Users\ct\eclipse-workspace-2019-06\DMModule2\lib\jOpenDocument-1.4rc2.jar
Caused by: java.lang.module.InvalidModuleDescriptorException: JDOMAbout$Info.class found in top-level directory (unnamed package not allowed in module)

我在模块路径、模块信息中拥有所有外部 jar 文件如下所示。

使用非模块化方法该项目可以顺利运行,但我想继续使用模块。 我发现这两个引用文献针对同一类问题

Mixed Modular and Non-Modular Development in Eclipse using Java 11

What do I need to build JDK 9 project with non-modular dependencies using Maven

但没有帮我解决。

jOpenDocument 的源代码已可用 https://jopendocument.org/download/jOpenDocument-src-1.4rc2.zip ,因此将 jar 更新为模块 通过添加 module-info 文件是可行的。我也尝试过,但没有成功,如果有人能做到这一点,我认为这对社区会有帮助。

module dmmodule2 {
      exports dmmodule;
      exports gui;

      // sql
      requires transitive java.sql;

      // Json
      requires transitive org.glassfish.java.json;

      // jOpenDocument
      requires transitive jOpenDocument;

      // JavaFX;
      requires javafx.fxml;
      requires transitive javafx.graphics;
      requires transitive javafx.controls;

      opens dmmodule to javafx.fxml;
      opens gui to javafx.fxml;
}

有没有人能提供一个提示,让我的模块化项目能够通过使用可用的 jOpenDocument 二进制 jar 或将其从源代码转换为模块来工作?

最佳答案

这是一个与 JDOM 相关的问题,我们将在下一版本的 jOpenDocument 中看看我们能做什么。

关于java - 模块化项目使用 jOpenDocument 引发 InvalidModuleDescriptorException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58299534/

相关文章:

java - JFace 的 MessageDialog 在 open() 方法中失败

java - 使用 Jetty 9 作为 Java 9 模块给出 ClassNotFoundException

java - JDK11迁移: Compilation error shown in Eclipse 2018-12 but code runs fine

java - 使用 java 自动模块 cdi.api 与 maven 和 java 9+

java - 如何在 SBT 中创建拼图模块?

java - Java中的compareTo(K)方法到底是如何工作的?

java - 命名 Java 对象

java - 从 java 类在 grails 中发送电子邮件

java-module - SecurityManager 弃用和通过抑制访问检查进行反射

Java 11 模块信息 : how to register an annotation processor