I have a jar built before Java 9. I'm trying to run a class that is in that jar using Java 9.
From all I read about automatic modules, this should work:
java -p lib/Legacy-1.3.0.jar -m Legacy/com.blah.MyClass
But instead I get this:
Error: Unable to initialize main class com.blah.MyClass in module module Legacy
Caused by: module Legacy: java.lang.NoClassDefFoundError
Yes, com.blah.MyClass is in Legacy. Can I run a class from an automatic module? Why is the word module
repeated twice in that error message above?
If I run java --list-modules -p lib/Legacy-1.3.0.jar
I see:
Legacy@1.3.0 file://path/to/jar/Legacy-1.3.0.jar automatic
If I run jdeps --generate-module-info . lib/Legacy-1.3.0.jar
, I get:
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;
}