title: How to run a class from a jar with from command-line with classpath specified
body: <p>I am trying to run a class from a JAR. This class is NOT the only main class in this jar. Also, it requires number of other jar files, which I have kept in the same directory as this Jar. The commands I have tried are as follows:</p>
  
  <p>(mydir is the directory in which all of my jars are located, using Windows platform)</p>
  
  <p><code>mysql-connector-java-5.1.13-bin.jar</code> is needed for <code>myProjImport.jar</code> to run and <code>com.mycomp.myProj.importer.csv.TestImporter</code> is the class i am trying to run. 
  <code>"C:\Documents and Settings\user\workspace\myProjImport\src\conf\datasource.properties"</code> and <code>"C:\temp\apollo_claims_test.txt"</code> are the command line arguments required by the class <code>TestImporter</code>
  Here is what I have tried:</p>
  
  <pre><code>mydir&gt;java -cp C:\temp\test_myProj\mysql-connector-java-5.1.13-bin.jar;. myProjImport.jar com.mycomp.myProj.importer.csv.TestImporter "C:\Documents and Settings\user\workspace\myProjImport\src\conf\datasource.properties" "C:\temp\apollo_claims_test.txt"
  </code></pre>
  
  <p>And here is the error:</p>
  
  <pre><code>Exception in thread "main" java.lang.NoClassDefFoundError: myProjImport/jar
  Caused by: java.lang.ClassNotFoundException: myProjImport.jar
          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: myProjImport.jar.  Program will exit.
  </code></pre>
  
  <p>Can someone please tell me what exact command should I run?</p>