I have 2 external jars in my referenced libraries.
Both of the jars have a package with the same name.
Is there any way to specify which jar i want to use in the import or a way to work around this?
I have 2 external jars in my referenced libraries.
Both of the jars have a package with the same name.
Is there any way to specify which jar i want to use in the import or a way to work around this?
In the file where you are using the class, you have to give the full class name.
public com.mongodb.connection getDbDetail(){}
Actually, there are two ways of solving your problem:
Having the same package name like com.mongodb
will not create any issue as long as the class name is unique. If both the jars have the same class name as ConnectionString
but in different packages, use the fully qualified class name like com.mongodb.ConnectionString
wherever referring to the corresponding class. If both the jars contain the same class name in the similar package, then you may end up something like NoSuchMethodError
while accessing a particular method.