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.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…