3

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.

Community
  • 1
  • 1
  • The other question discussed _quoting_ `lib/*` but I actually wonder if the `*` is ever _expanded_? `javac` probably wont do that, it has to be expanded before the command is executed. I can't tell you anything about `*` expansion on windows, though ... – Stephan Herrmann Mar 29 '18 at 20:53
  • @StephanHerrmann `lib/*` - this works fine for me on Windows. It takes all jars under `lib` directory to the classpath. As I mentioned, when I remove `module-info.java` and `--add-modules simpleModule` it treats classes under `simpleModule` as non-modular and compiles without problem – David stands with Ukraine Mar 30 '18 at 07:09
  • I found "It is possible to put arbitrary classes and JAR files on the class path in this compile mode, but that is not recommended since it amounts to treating those classes and JAR files as part of the module being compiled." here http://openjdk.java.net/jeps/261#Compile-time Can somebody explain it? – David stands with Ukraine Apr 02 '18 at 06:36

1 Answers1

2

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.

Jose Henriquez
  • 356
  • 2
  • 7