繁体   English   中英

Eclipse 无法运行 java 项目并出现模块警告

[英]Eclipse can't run java project with module warning

我正在使用 OpenJDK-14 运行 eclipse 4.16。 我有一个简单的 java 项目,其中有一个包含 swt.jar 的 lib 文件夹。 它被添加到项目的 Properties > Java build path > Libraries 对话框中的模块路径中。 当我在 class 中导入和使用 swt class 时,系统会提示我向我的模块信息文件添加一个条目。 它添加了带有警告的“swt”:

Name of automatic module 'swt' is unstable, it is derived from the module's file name.

当我尝试将项目作为 java 应用程序运行时,我在控制台中收到此错误并且没有运行:

Error occurred during initialization of boot layer
java.lang.module.FindException: Module swt not found, required by ca.footeware.swt.converter

如果我将项目导出为可运行的 jar 并附带依赖项,则它会出现类似的警告。 导出的 jar 确实可以运行(但这不是一个方便的开发周期:)

我在某处读到,对于非模块化 jars,可以使用 MANIFEST.MF header,自动模块名称。 I cracked open the swt.jar and added the header with value org.eclipse.swt, the root package of the jar. 我删除了 Requires swt; 来自我的 module-info.java 并再次被提示从我的 class 中添加一个带有 swt 导入的条目。 这次虽然进入 Requires org.eclipse.swt; 并且没有产生警告。 当我尝试运行该项目时,我得到了同样的错误:

Error occurred during initialization of boot layer
java.lang.module.FindException: Module org.eclipse.swt not found, required by ca.footeware.swt.converter

我得到了它的工作:我的运行配置的 VM args 现在是:

--module-path ca.footeware.converter:ca.footeware.converter.temperature:/home/craig/Downloads/swt.jar -m ca.footeware.converter/ca.footeware.converter.Converter

我在 linux 上,--module-path 分隔符应该是:,不是;。

注意我已经将运行配置的工作目录设置为 ${workspace_loc} 而不是默认的 ${workspace_loc:ca.footeware.converter} 以便我可以通过简单名称而不是完全限定名称来访问两个模块项目,例如 /home/克雷格/工作区/ca.footeware.converter.temperature。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM