If I have multiple files of the same name on classpath (e.g. I have multiple .jar with log4j.properties), what are the rules JVM follows to chose one?
If I have multiple files of the same name on classpath (e.g. I have
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It is specified by the order in which the resources (i.e. usually jar files) are specified using
-classpathoption. 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-classpathoption. 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.