I am trying to run a simple Java project. I had created a project using the \'Maven Project\' type. I have one main class called \'TestMain\'. When I tried to run the projec
Well, you need to incorporate exec-maven-plugin, this plug-in performs the same thing that you do on command prompt when you type in java -cp .;jarpaths TestMain. You can pass argument and define which phase (test, package, integration, verify, or deploy), you want this plug-in to call your main class.
You need to add this plug-in under tag and specify parameters. For example
...
...
org.codehaus.mojo
exec-maven-plugin
1.1.1
test
java
my.company.name.packageName.TestMain
myArg1
myArg2
...
...
Now, if you right-click on on the project folder and do Run As > Maven Test, or Run As > Maven Package or Run As > Maven Install, the test phase will execute and so your Main class.