title: Loading two classes in different JARs
body: <p>I got two classes with the same package in different JARs. Until the previous version, both classes were identical, so i had no issues in loading them. Now, one of them has a new method added and if I want to access it, not only should I import the class with that package, i also need to make sure the jar with the correct class comes first in the classpath.</p>
  
  <p>i.e. <code>javac -classpath "%classpath%;a.jar;b.jar" MyClasses..</code></p>
  
  <p>where <code>a.jar</code> has the class with my new method.</p>
  
  <p>Now, how do i ensure this when my app goes to production, where it's deployed as an EAR file, with all the libraries under WEB-INF/lib?</p>
  
  <p>How do I know which jar gets the preference over the other? Is it the alphabetical order like a.jar is given the first preference over b.jar?</p>
  
  <p>I've read this <a href="https://stackoverflow.com/questions/2107911/safe-class-imports-from-jar-files">safe-class-imports-from-jar-files</a> thread and got to know about writing a custom classloader, but is there a better simpler solution that? Cos I'm just going to access this method in that whole JAR in this current project and writing a classloader seems a bit overkill.</p>
  
  <p>And please don't ask me "Why the hell same class with same package in different JARs?" It's <strong>absolutely out of my control</strong> and it'll take some time to get this corrected.</p>
  
  <p>Environment details: IBM WAS 6.1 on their 1.5 Java.</p>
  
  <p>Please ask me more questions, if I don't make much sense. Thanks in advance!</p>