Mix --class-path and --module-path in javac (JDK 9)

 ̄綄美尐妖づ 提交于 2019-12-19 04:46:07

问题


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

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

lib - directory with my libraries-jars

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

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

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


回答1:


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

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

I tested the above using JDK 11.0.1.



来源:https://stackoverflow.com/questions/49537980/mix-class-path-and-module-path-in-javac-jdk-9

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!