title: How to run java program from cmd line with classpath and native libraries?
body: <p>Ok I give up - I dont have a lot of xp running java from cmd line and I've been at this for a while, tried endless combinations and I am just frustrated so here we go.</p>
  
  <p>I need to run a simple java app (with dependencies on a bunch of jars that then depend on some native libraries) from cmd line - I am in the bin folder when I try to run the following:</p>
  
  <pre><code>java -Djava.library.path="../lib" -cp ../jar;. MyMainClass
  </code></pre>
  
  <p>No matter the order (i understand the order counts!) this does not work, with different errors.</p>
  
  <p>For example the version I have pasted above gives me a list of the cmd line params followed by:</p>
  
  <pre><code>-bash: myMainClass: No such file or directory
  </code></pre>
  
  <p>but MyMainClass.class is there in the bin folder from which I am running the stuff.</p>
  
  <p>If I try this instead:</p>
  
  <pre><code>java -Djava.library.path="../lib" AlphaHHKernel_Tuning_Test -cp ../jar;.
  </code></pre>
  
  <p>I get: </p>
  
  <pre><code>Exception in thread "main" java.lang.NoClassDefFoundError: MyMainClass
  Caused by: java.lang.ClassNotFoundException: MyMainClass
      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)
  -bash: .: filename argument required
  .: usage: . filename [arguments]
  </code></pre>
  
  <p>I'd like to understand how those attributes are supposed to be used (and get it to work in the process).</p>