title: Java Classloader - how to reference different versions of a jar
body: <p>This is a common problem. I'm using 2 libraries <strong>A.jar</strong> and <strong>B.jar</strong> and these depend on different versions of the same jar.<br>
  Let's say that at runtime I need <strong>THIS.x.x.x.jar</strong></p>
  
  <pre><code>MY.jar   
       -&gt; A.jar -&gt; THIS.1.0.0.jar
       -&gt; B.jar -&gt; C.jar -&gt; THIS.5.0.0.jar
  </code></pre>
  
  <p>I can compile the specific jar (A.jar/B.jar) against its dependency but at runtime I've to load only 1 version. Which one?<br>
  Loading only 1 dependency (the latest version) means that my code will probably throw runtime exceptions if the libraries are not Backward Compatible (are there Backward Compatible libraries out there?).</p>
  
  <p>Anyway I know that something like OSGi can fix this issue.<br>
  I'm wondering what's the old way to fix this kind of problems...</p>
  
  <p>Thanks a lot</p>