| Author |
same name java classes in different JAR
|
Jean-Claude Serlet
Greenhorn
Joined: Aug 19, 2005
Posts: 2
|
|
Hello What i don't find is the method used by the JVM when a class is requested and this class may be found in two different jar files under the classpath I know that it's a vary bad organisation ( A sample : in class A there is an instanciation of class B B machin = new B(); In the classpath there are two jar files (file1.jar and file2.jar) each containing a class B Which class B will be used : B of file1.jar or B of file2.jar ? Why ? Regards Jean-Claude
|
 |
Paul Sturrock
Bartender
Joined: Apr 14, 2004
Posts: 10336
|
|
|
Assuming the fully qualified class names are the same, I'd guess the class loaded would be the first class the classloader finds. You could find out by jaring up two identically named class files in different jars, putting them both in the classpath and using this class from an application. Chuck a bit of logging in each class to say which one it is.
|
JavaRanch FAQ HowToAskQuestionsOnJavaRanch
|
 |
Jean-Claude Serlet
Greenhorn
Joined: Aug 19, 2005
Posts: 2
|
|
Thanks I'll try what you explain Regards
|
 |
 |
|
|
subject: same name java classes in different JAR
|
|
|