在javac中混合--class-path和--module-path(JDK 9) [英] Mix --class-path and --module-path in javac (JDK 9)

查看:1077
本文介绍了在javac中混合--class-path和--module-path(JDK 9)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图按照问题但它确实对我有用。
我想编译1个模块(不需要任何其他模块或jar)以及其他使用该模块的类,并且将在未命名的模块中。

I tried to follow this question but it does`t work for me. I want to compile 1 module (which does not requires any other module or jar) together with other classes which use this module and will be in unnamed module.

javac -cp lib\* --module-path modules --add-modules simpleModule -d out @classes.txt

运行此命令后,我得到package org ....不存在。但是带有这个包的jar在lib目录中

After I run this command I get " package org.... does not exist". But jar with this package is in lib directory

lib - 带有我的libraries-jars的目录

lib - directory with my libraries-jars

modules - 这个文件夹包含模块simpleModulewith module-info.java

modules - this folder contains module "simpleModule" with module-info.java

@ classes.txt - 要编译的所有类列表(包括模块化和非模块化)。操作系统 - Windows

@classes.txt - all list of classes to compile (including modular and non modular). OS - Windows

当我从simpleModule中删除module-info.java时,一切都编译得很好。

When I remove module-info.java from simpleModule everything compiles well.

推荐答案

老问题,但最近我在使用模块和非模块jar工作项目时遇到了一个相关问题。根据您的示例命令行,如果您的模块位于 jar 中,请使用以下命令行:

Old question, but I came across a related issue recently when working on a project using module and non-module jars. Based on your example command line, use the following command line if your module is in a jar:

javac -cp lib\*.jar -d out @classes.txt

如果模块不在 jar 中,意思是展开目录,这将是命令:

If the module is not in a jar, meaning exploded directory, this will be the command:

javac -cp mods\moduled.in.question -d out @classes.txt

我使用JDK 11.0.1测试了上述内容。

I tested the above using JDK 11.0.1.

这篇关于在javac中混合--class-path和--module-path(JDK 9)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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