I was facing this issue too,
It was because of DocumentBuilderFactory
is available in other packages too.
Reason
Sometimes dependencies
take transitive dependencies
along with it self
For example
Class XYZ
is available in jarA
, JarB
and JarC
too. This issue was not visible untill Java8
but after Java9
release, Java9
release with Java Platform Module System.
This module system restrict to have multiple classes in different jars with same name, I am not saying that we can not have same name in different classes, for this you have to write module-info.java
and have to convert your application into Module System
.
If you are not planning to move your application into Module System
then you can do one this, remove the dependencies which are not required for your applications and have same named classes.
Like for your problem what you can do
- Open project in
eclipse
- Press
ctrl
+ shit
+ T
>
- Dialog opens> write your class name which is creating problem, >
- Dialog will show the packages which contains the same
class
, Now
find out the package which is not required or transitive property
because of other dependency >
Right click
on package name and click show in
Package Explorer
>
- Now you will have the
jar
name, remove
or exclude
that jar
from your dependency manager, Like Gradle
or Maven
Or Ivy
I know lengthy process, but its your application your love you have to maintain this.