Java 9:运行旧版jar

Bob*_*ley 5 java java-9 java-module

我在Java 9之前构建了一个jar。我正在尝试使用Java 9运行该jar中的类。

从我读到的有关自动模块的所有内容来看,这应该可以工作:

java -p lib/Legacy-1.3.0.jar -m Legacy/com.blah.MyClass
Run Code Online (Sandbox Code Playgroud)

但是我得到了这个:

Error: Unable to initialize main class com.blah.MyClass in module module Legacy
Caused by: module Legacy: java.lang.NoClassDefFoundError
Run Code Online (Sandbox Code Playgroud)

是的,com.blah.MyClass是旧版。我可以从自动模块中运行课程吗?为什么module在上面的错误消息中单词重复两次?

如果我跑步,java --list-modules -p lib/Legacy-1.3.0.jar我会看到:

Legacy@1.3.0 file://path/to/jar/Legacy-1.3.0.jar automatic
Run Code Online (Sandbox Code Playgroud)

如果我跑步jdeps --generate-module-info . lib/Legacy-1.3.0.jar,我得到:

module Legacy {
    requires java.logging;

    requires transitive java.activation;
    requires transitive java.xml;
    requires transitive java.xml.bind;
    requires transitive java.xml.ws;

    exports com.blah;
}
Run Code Online (Sandbox Code Playgroud)