0

My Application (ear) has 2 jar and 2 war files. I want to find out if a properties file (xyz.xml) appear twice or more in the class path. I tried withURL url = Thread.currentThread().getContextClassLoader().getResource("xyz.xml"); . But this process return only the 1st appearance of the properties file. It's stop looking further once it gets the file in any jar/war. But , I do need all the occurrences of this properties file in my application. I am new in Java EE world, spend plenty of time to figure this out.

Any help will be highly appreciated. Thanks in advance.

  • 1
    Possible duplicate of [Find duplicated classes in classpath](https://stackoverflow.com/questions/12536482/find-duplicated-classes-in-classpath) – vorburger Oct 03 '18 at 23:32

1 Answers1

0

Try with:

Enumeration<URL> urls = Thread.currentThread().getContextClassLoader().getResources("xyz.xml");

This finds all the resources with the given name.

See more: https://docs.oracle.com/javase/7/docs/api/java/lang/ClassLoader.html#getResources%28java.lang.String%29

Federico Sierra
  • 5,118
  • 2
  • 23
  • 36