how to avoid "duplicate class" in Java
<p>Suppose I have have a java project <code>myProject</code> and am using an external library jar (<code>someJar.jar</code>), which has a class <code>com.somepackage.Class1.class</code>.</p>

<p>Now I find an updated version of <code>Class1.java</code> which fixes a bug in the original jar.</p>

<p>I include the new <code>Class1.java</code> in my source code under package <code>com.somepackage</code></p>

<p>When I build the project (e.g., using Netbeans), there is a <code>dist\myProject.jar</code> which contains the class<code>com.somepackage.Class1.class</code> and a <code>dist\lib\someJar.jar</code> which also contains a class with the same name.</p>

<p>When I run the file (e.g, using <code>java -jar dist\myProject.jar</code>), the new version of <code>Class1.class</code> is used (as I want). </p>

<ol>
<li><p>How does Java decide which class file to run in case of such duplicates? Is there any way I can specify precedence ?</p></li>
<li><p>Is there any 'right' way to avoid such clashes? </p></li>
<li><p>In Proguard, when I try to compress my code, I get a <code>duplicate class</code> error. How do I eliminate this?</p></li>
</ol>
