Getting java.lang.NoClassDefFoundError when trying the execute a java.class
<p>I created the following class located in the MainJPrint.java file</p>

<pre><code>import com.XXXXX.pdfPrint.PDFPrint;

public class MainJPrint
{
   public static void main(String[] args) 
    { 
        //System.out.println("Hello World!"); 
        print(".....");
    }   
    public static String print (final String url)
    {
        Object rc = AccessController.doPrivileged(new java.security.PrivilegedAction() 
        {
            public Object run()
            {
                 ...
            }
         }
    }
}
</code></pre>

<p>In the same folder I have a jar archive <strong>jPrint.jar</strong>
I compile the class using the following command</p>

<pre><code>&gt;javac -classpath jPrint.jar MainJPrint.java
</code></pre>

<p>When I'm trying to execute resulted class file, I get this error:</p>

<pre><code>&gt;java MainJPrint    

 java.lang.NoClassDefFoundError: com/XXXXX/pdfPrint/PDFPrint
</code></pre>

<p>If I uncomment the Hello World line and comment the next line, the program runs fine.</p>

<p>I'm using j2sdk1.4.2 installed at <code>C:\j2sdk1.4.2</code>.
I do also have installed other java versions (at C:\Program Files\Java: jre 1.6.0_01, jre 1.6.0_02, j2re1.4.2, jre6, jre7, jdk1.7.0_03)</p>

<p>The PATH variable contains the <code>C:\j2sdk1.4.2\bin</code> path, however I think the java.exe is loaded from the upper version, but it shouldn't matter and I can call it like </p>

<pre><code>&gt;C:\j2sdk1.4.2\bin\java.exe MainJPrint
</code></pre>

<p>jPrint.jar is a third party archive and I need to create an applet which exposes a method so I can call it with javascript. I'm not a java developer, I'm having some little troubles and I'm really on an end here.</p>

<p>I tried other options like:</p>

<pre><code>&gt;java MainJPrint -cp .
&gt;java MainJPrint -cp jPrint.jar
</code></pre>

<p>So how can I execute that class file which uses a class located in a separate archive?</p>
