Reputation: 23492
What happens, if there is a manifest Class-Path entry for a jar which doesn't exists at the location, but is available by another means (in the lib-folder of application server for example)
Will the unresolved Class-Path entry cause any errors?
Upvotes: 0
Views: 318
Reputation: 3673
JVM loads & searches classes in following order:
If the JAR-class-path points to a JAR file that was already included (for example, an extension, or a JAR file that was listed earlier in the class path) then that JAR file will not be searched again. (This optimization improves efficiency and prevents circular searches.) Such a JAR file is searched at the point that it appears, earlier in the class path.
To verify this, I also did following test 1. Created lib(jar) "classpath-test" containing a Util class. 2. Created another lib(jar) i.e wrapper-lib which uses classpath-test's Util class. 3. In wrapper-lib's MANIFEST.MF, added below entry.
Class-Path: lib/classpath-test.jar
Copied classpath-test.jar under lib dir and ran below command
java -jar wrapper-lib.jar
Above command Ran fine. Ran same command after deleting lib/classpath-test.jar, and it failed.
Another test, deleted classpath-test.jar from lib & copied in JAVA_HOME/lib/ext and ran
java -jar wrapper-lib.jar
It worked.
Upvotes: 1