Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8175764 | 10 | Vicente Arturo Romero Zaldivar | P2 | Resolved | Fixed | b02 |
When trying to run a jar on an image that does not contain all required modules, instead of a helpful error message I get:
/img/bin/java -jar ./JDK9ModularJar/anagrams.jar
Error: Could not find or load main class com.toy.anagrams.ui.Anagrams
When trying to launch as a module I get a more understandable error:
./img/bin/java --module-path ./JDK9ModularJar -m AnagramGame
Error occurred during initialization of VM
java.lang.module.ResolutionException: Module java.desktop not found, required by AnagramGame
at java.lang.module.Resolver.fail(java.base@9-ea/Resolver.java:850)
at java.lang.module.Resolver.resolve(java.base@9-ea/Resolver.java:155)
at java.lang.module.Resolver.resolveRequires(java.base@9-ea/Resolver.java:117)
at java.lang.module.Configuration.resolveRequiresAndUses(java.base@9-ea/Configuration.java:311)
at java.lang.module.ModuleDescriptor$1.resolveRequiresAndUses(java.base@9-ea/ModuleDescriptor.java:2522)
at jdk.internal.module.ModuleBootstrap.boot(java.base@9-ea/ModuleBootstrap.java:278)
at java.lang.System.initPhase2(java.base@9-ea/System.java:1928)
Steps to reproduce:
1) Create a modular jar that requires more than java.base, in my example I used the Anagram game sample from Netbeans.
2) Use jlink to create a runtime that only includes the base module
3) Try to run the jar with the custom image specifying it as a jar, not as a module.
Expected: Some error saying that required modules XYZ are not found, similar to the error displayed if I try to launch the jar as a module.
/img/bin/java -jar ./JDK9ModularJar/anagrams.jar
Error: Could not find or load main class com.toy.anagrams.ui.Anagrams
When trying to launch as a module I get a more understandable error:
./img/bin/java --module-path ./JDK9ModularJar -m AnagramGame
Error occurred during initialization of VM
java.lang.module.ResolutionException: Module java.desktop not found, required by AnagramGame
at java.lang.module.Resolver.fail(java.base@9-ea/Resolver.java:850)
at java.lang.module.Resolver.resolve(java.base@9-ea/Resolver.java:155)
at java.lang.module.Resolver.resolveRequires(java.base@9-ea/Resolver.java:117)
at java.lang.module.Configuration.resolveRequiresAndUses(java.base@9-ea/Configuration.java:311)
at java.lang.module.ModuleDescriptor$1.resolveRequiresAndUses(java.base@9-ea/ModuleDescriptor.java:2522)
at jdk.internal.module.ModuleBootstrap.boot(java.base@9-ea/ModuleBootstrap.java:278)
at java.lang.System.initPhase2(java.base@9-ea/System.java:1928)
Steps to reproduce:
1) Create a modular jar that requires more than java.base, in my example I used the Anagram game sample from Netbeans.
2) Use jlink to create a runtime that only includes the base module
3) Try to run the jar with the custom image specifying it as a jar, not as a module.
Expected: Some error saying that required modules XYZ are not found, similar to the error displayed if I try to launch the jar as a module.
- backported by
-
JDK-8175764 improve error message shown when main class can't be loaded
-
- Resolved
-