This was a question that I also came to. Even if when using java -cp ..;myTest.jar test2.Needer I get only "..; myTest.jar" as a result for the java.class.path property.
Note. Even when you use the -cp parameter, the specified class path is searched in MANIFEST.MF ! (Could not find this information on Google and verify itself)
Therefore, I do not think this has anything to do with the -jar parameter. In Link you can find
Wildcard expansion is performed earlier than the main program method call, and not late, during the class loading process itself.
Interestingly, I found out during my tests: the classpath in MANFIFEST.MF is usually recursive. Therefore, if there is a specified test.jar in the MANIFEST.MF myTest.jar test.jar file. The file is in the class path, the class path in the MANIFEST.MF test.jar file will also be considered (using java -cp "myTest.jar" test2.Needer )
As a result, when the java.class.path property supports showing the path to the MANIFEST.MF classes, it should also display classpathes of all subsequently dependent .jar files. Since the class path is only executed until the classes are found, this will not apply well to the lazy loading mechanism.
TL DR : I think this has nothing to do with the -jar Parameter ( -cp ) parameter. In my explanation, the support for showing the classpath from MANIFEST.MF will only come with additional meaningless recursive search costs (because it does not have to be an actual dependency, with respect that is used from .jar). And since this meaningless search will delay the start of the program (since the recursive search can be really deep), it is not implemented.
source share