Java: Which of multiple resources on classpath JVM takes?

It is specified by the order in which the resources (i.e. usually jar files) are specified using -classpath option. Resources ‘earlier’ on the classpath take precedence over resources that are specified after them. This can be also set in the manifest file of your application and then you don’t need to provide -classpath option. You may want to check these articles on how to work with manifest files.

The exhaustive description of “how classes are found” can be found here, where the section on JAR-class-path Classes describes the logic of JAR-files searching.

Leave a Comment