title: How to run a java file via maven?
body: <p>How can I execute <code>SampleFlowTest.java</code> via maven?</p>
  
  <p>The code inside <code>SampleFlowTest.java</code> is:</p>
  
  <pre><code>package com.myname.module.test;
  
  import com.myname.partA.something;
  import java.util.Scanner;
  import java.util.ArrayList;
  
  public class SampleFlowTest {
      public static void main(String[] args) {
          // something I want to execute
      }
  }
  </code></pre>
  
  <p>The files tree is as below.</p>
  
  <pre><code>.
  ├── pom.xml
  ├── resource
  │   ├── fileA.txt
  │   └── fileB.txt
  ├── src
  │   ├── main
  │   │   └── java
  │   │       └── com
  │   │           └── myname
  │   │               ├── partA
  │   │               │   └── Aaa.java
  │   │               ├── partB
  │   │               │   ├── B.java
  │   │               │   ├── Bb.java
  │   │               │   └── Bbb.java
  │   │               └── module
  │   │                   ├── M1.java
  │   │                   └── M2.java
  │   └── test
  │       └── java
  │           └── com
  │               └── myname
  │                   ├── partA
  │                   │   └── test
  │                   │       └── AaaTest.java
  │                   ├── partC
  │                   │   └── service
  │                   │       └── test
  │                   │           ├── BTest.java
  │                   │           └── BbbTest.java
  │                   └── module
  │                       └── test
  │                           └── SampleFlowTest.java
  └── target
      ├── classes
      │   ├── com
      │   │   └── myname
      │   │       ├── partA
      │   │       │   └── Aaa.class
      │   │       ├── partB
      │   │       │   ├── B.class
      │   │       │   ├── Bb.class
      │   │       │   └── Bbb.class
      │   │       └── module
      │   │           ├── M1.class
      │   │           └── M2.class
      │   └── somefile.txt
      └── test-classes
          ├── com
          │   └── myname
          │       ├── partA
          │       │   └── test
          │       │       └── AaaTest.class
          │       ├── partC
          │       │   └── service
          │       │       └── test
          │       │           ├── BTest.class
          │       │           └── BbbTest.class
          │       └── module
          │           └── test
          │               └── SampleFlowTest.class
          └── module.properties
  </code></pre>
  
  <p>I have tried like <a href="https://stackoverflow.com/questions/10108374/maven-how-to-run-a-java-file-from-command-line-passing-arguments">Maven: How to run a .java file from command line passing arguments</a> said but it still doesn't work.</p>
  
  <p>I executed <code>mvn exec:java -Dexec.mainClass=com.myname.module.test.SampleFlowTest</code>, and error occurred , part of the result is:</p>
  
  <pre><code>[WARNING] 
  java.lang.ClassNotFoundException: com.myname.module.test.SampleFlowTest
      at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
      at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:281)
      at java.lang.Thread.run(Thread.java:745)
  </code></pre>
  
  <p>What command should I execute other than <code>mvn exec:java -Dexec.mainClass=com.myname.module.test.SampleFlowTest</code>?</p>