title: Running an Eclipse Java Maven project from a Windows (DOS) shell
body: <p><strong>Summary:</strong> How to run an Eclipse Java Maven Project outside of Eclipse  </p>
  
  <p><strong>Details:</strong></p>
  
  <p>I am a Maven newbie and I have created a very simple Maven project in Eclipse.  </p>
  
  <p>The Package Explorer view of my project is as follows:</p>
  
  <p><a href="https://i.stack.imgur.com/MOST7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MOST7.png" alt="enter image description here"></a><br>
  The source code for the two simple Java files is as follows:    </p>
  
  <pre><code>package Pkg01;
  
  public class Calculator
  {
    public double add(double number1, double number2)
    {
      return number1 + number2;
    }
  
    public static void main(String[] args) {
        Calculator calculator = new Calculator();
  
        System.out.println(calculator.add(100, 200));
    }
  }
  </code></pre>
  
  <p>and  </p>
  
  <pre><code>package Pkg01;
  
  import junit.framework.TestCase;
  
  public class TestCalculator extends TestCase
  {
    public void testAdd()
    {
      Calculator calculator = new Calculator();
      double result = calculator.add(10, 50);
      assertEquals(60, result, 0);
    }
  }  
  </code></pre>
  
  <p>From within Eclipse I am able to run the Java Application, the Junit Test and the Maven test, without any issues.  </p>
  
  <p>My question is how can I invoke the <code>mvn</code> command from the DOS shell so that I can:  </p>
  
  <ol>
  <li>Run the Java Application</li>
  <li>Run the Junit Test</li>
  <li>Run the Maven test</li>
  </ol>
  
  <p>BTW running <code>mvn exec:java</code> from the parent directory of the project <strong>is not</strong> executing the Java application for me.  </p>
  
  <p>My <code>pom.xml</code> file looks like this:  </p>
  
  <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
    &lt;groupId&gt;org.newbie&lt;/groupId&gt;
    &lt;artifactId&gt;Stackoverflow&lt;/artifactId&gt;
    &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
    &lt;packaging&gt;jar&lt;/packaging&gt;
  
    &lt;name&gt;Stackoverflow&lt;/name&gt;
    &lt;url&gt;http://maven.apache.org&lt;/url&gt;
  
    &lt;properties&gt;
      &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
    &lt;/properties&gt;
  
    &lt;dependencies&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;junit&lt;/groupId&gt;
        &lt;artifactId&gt;junit&lt;/artifactId&gt;
        &lt;version&gt;3.8.1&lt;/version&gt;
        &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
    &lt;/dependencies&gt;
  &lt;/project&gt; 
  </code></pre>
  
  <p><code>mvn exec:java</code> gives the following error:  </p>
  
  <pre><code>[INFO] Scanning for projects...
  [INFO]
  [INFO] ----------------------&lt; org.newbie:Stackoverflow &gt;----------------------
  [INFO] Building Stackoverflow 0.0.1-SNAPSHOT
  [INFO] --------------------------------[ jar ]---------------------------------
  [INFO]
  [INFO] --- exec-maven-plugin:1.6.0:java (default-cli) @ Stackoverflow ---
  [INFO] ------------------------------------------------------------------------
  [INFO] BUILD FAILURE
  [INFO] ------------------------------------------------------------------------
  [INFO] Total time:  0.957 s
  [INFO] Finished at: 2019-11-05T22:47:00-06:00
  [INFO] ------------------------------------------------------------------------
  [ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.6.0:java (default-cli) on project Stackoverflow: The parameters 'mainClass' for goal org.codehaus.mojo:exec-maven-plugin:1.6.0:java are missing or invalid -&gt; [Help 1]
  [ERROR]
  [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
  [ERROR] Re-run Maven using the -X switch to enable full debug logging.
  [ERROR]
  [ERROR] For more information about the errors and possible solutions, please read the following articles:
  [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginParameterException  
  </code></pre>
  
  <hr>
  
  <p><strong>Here are the reasons why I feel that my question is <a href="https://stackoverflow.com/questions/19850956">not a duplicate</a>.</strong>  </p>
  
  <p>I created a very simple project with maven-archetype-quickstart and my environment is correct because everything {i.e. (1) Run the Java Application, (2) Run the Junit Test and (3) Run the Maven test} works for me within the Eclipse IDE environment.  The other poster was having trouble executing, <strong>which I don’t.</strong>  </p>
  
  <p>The comments that the other poster received were mainly for fixing his environment to get it running.  I don't have that issue since, as already mentioned, everything works for me within the Eclipse IDE environment.</p>
  
  <p>All I am asking is what I need to do get the following things working from the command shell:  </p>
  
  <ol>
  <li>Running the Java Application</li>
  <li>Running the Junit Test</li>
  <li>Running the Maven test</li>
  </ol>