title: Program cannot find RequestEntity class even though jar is included with compile
body: <p>I build a very simple test program to submit an HTTP Post to a webserver with an XML payload.  I'm including the <code>jar</code> file <code>commons-httpclient-3.1.jar</code> which contains the RequestEntity class, but when I run the program I get the following error and I cannot determine why it cannot find the class.</p>
  
  <p>My <code>javac</code> command:</p>
  
  <pre><code> javac -verbose -d classes -sourcepath src -cp lib\commons-httpclient-3.1.jar; src\testpartstorepost\PostXML2.java
  </code></pre>
  
  <p>Verbose output shows it load the <code>RequestEntity.class</code></p>
  
  <pre><code>[parsing started src\testpartstorepost\PostXML2.java]
  [parsing completed 32ms]
  [search path for source files: src]
  [search path for class files: ***SNIP***
  [loading java\io\File.class(java\io:File.class)]
  [loading org\apache\commons\httpclient\HttpClient.class(org\apache\commons\httpclient:HttpClient.class)]
  [loading org\apache\commons\httpclient\methods\FileRequestEntity.class(org\apache\commons\httpclient\methods:FileRequestEntity.class)]
  [loading org\apache\commons\httpclient\methods\PostMethod.class(org\apache\commons\httpclient\methods:PostMethod.class)]
  [loading org\apache\commons\httpclient\methods\RequestEntity.class(org\apache\commons\httpclient\methods:RequestEntity.class)]
  [loading java\lang\Object.class(java\lang:Object.class)]
  [loading java\lang\String.class(java\lang:String.class)]
  [loading java\lang\Exception.class(java\lang:Exception.class)]
  [checking testpartstorepost.PostXML2]
  [loading java\lang\Throwable.class(java\lang:Throwable.class)]
  [loading java\net\URI.class(java\net:URI.class)]
  [loading org\apache\commons\httpclient\methods\EntityEnclosingMethod.class(org\apache\commons\httpclient\methods:EntityEnclosingMethod.class)]
  [loading org\apache\commons\httpclient\methods\ExpectContinueMethod.class(org\apache\commons\httpclient\methods:ExpectContinueMethod.class)]
  [loading org\apache\commons\httpclient\HttpMethodBase.class(org\apache\commons\httpclient:HttpMethodBase.class)]
  [loading org\apache\commons\httpclient\HostConfiguration.class(org\apache\commons\httpclient:HostConfiguration.class)]
  [loading org\apache\commons\httpclient\HttpMethod.class(org\apache\commons\httpclient:HttpMethod.class)]
  [loading java\lang\System.class(java\lang:System.class)]
  [loading java\io\PrintStream.class(java\io:PrintStream.class)]
  [loading java\io\FilterOutputStream.class(java\io:FilterOutputStream.class)]
  [loading java\io\OutputStream.class(java\io:OutputStream.class)]
  [loading java\lang\Error.class(java\lang:Error.class)]
  [loading java\io\IOException.class(java\io:IOException.class)]
  [loading java\lang\RuntimeException.class(java\lang:RuntimeException.class)]
  [loading org\apache\commons\httpclient\HttpException.class(org\apache\commons\httpclient:HttpException.class)]
  [loading java\lang\StringBuilder.class(java\lang:StringBuilder.class)]
  [loading java\lang\AbstractStringBuilder.class(java\lang:AbstractStringBuilder.class)]
  [loading java\lang\CharSequence.class(java\lang:CharSequence.class)]
  [loading java\io\Serializable.class(java\io:Serializable.class)]
  [loading java\lang\Comparable.class(java\lang:Comparable.class)]
  [loading java\lang\StringBuffer.class(java\lang:StringBuffer.class)]
  [wrote classes\testpartstorepost\PostXML2.class]
  </code></pre>
  
  <p>But when I run the program I get the following:</p>
  
  <pre><code>D:\java testpartstorepost/PostXML2
  Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/httpclient/methods/RequestEntity
  Caused by: java.lang.ClassNotFoundException: org.apache.commons.httpclient.methods.RequestEntity
          at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
          at java.security.AccessController.doPrivileged(Native Method)
          at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
          at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
  Could not find the main class: testpartstorepost/PostXML2.  Program will exit.
  </code></pre>
  
  <p>I can provide the java source too if needed.  I cannot determine why the program cannot find the RequestEntity</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>If I change my java call to point to the right <code>classpath</code> I get further, think this one is solved.</p>
  
  <pre><code>java -cp .;..\lib\commons-httpclient-3.1.jar; testpartstorepost/PostXML2
  </code></pre>