I have two .jar files having same package structure and same class name.
Eg. math.jar and state.jar
package structure is com.myorg.common
and both jars having class called Util
Now, When i use the class in program…Object of which class will be created at run time?
and what if i wanted to create an object of specific class? (that is from math.jar)
It will depend on the order in which the jar files appear in the classpath. I believe the one that appears first in the classpath will be used. Any one classloader can only have a single class with a particular fully-qualified name.
Basically, this is a really bad idea – don’t have the same class in the same package in multiple places; it’s just asking for trouble.