How do I find a duplicate class on the class path?
Background:
I suspect to have a duplicate class (javax.mail.Session). I found one jar with this class, but I have no idea where the second jar containing the same class is.
I am using Eclipse.
You can get all classpath roots by passing an empty String into ClassLoader#getResources() . Enumeration<URL> roots = classLoader. getResources("");
The "duplicate class" error can also occur when the class is named the same with the same package naming hierarchy, even if one of the classes exists in a directory structure with directory names different than the package names. This is shown in the next screen snapshot.
In eclipse press ctrl-shift-T and type Session:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With