title: Maven: How to run a .java file from command line passing arguments
body: <p>I have the following problem. I would like to run <code>mvn</code> from command line for a <code>Main.java</code> file. <code>Main.java</code> accepts a parameter. <strong>How do I do that from command line?</strong></p>
  
  <p>I tried finding an example but I was not successful. Could someone help me by giving me an example of that?</p>
  
  <p>I looked <a href="http://www.vineetmanohar.com/2009/11/3-ways-to-run-java-main-from-maven/" rel="noreferrer">here</a> but didn't quite understand what I should do.</p>
  
  <p>Also, <strong>how do I execute that command from a different folder than the Main.java folder?</strong></p>
  
  <p>for example the <code>Main.java</code> is located in <code>my/java/program/Main.java</code>. 
  What should I put in</p>
  
  <pre><code>mvn exec:java -Dexec.mainClass="what to put here?" -Dexec.args="arg0 arg1 arg2"
  </code></pre>