views:

1289

answers:

3
+2  Q: 

Maven Run Project

Is there a Maven "phase" or "goal" to simply execute the main method of a Java class? I have a project that I'd like to test manually by simply doing something like "mvn run".

+1  A: 

Not sure why you want to do this. If you are developing in an IDE you can debug a type with a main method. What would be the benefit of using Maven to start the application?

Rich Seller
There are quite a few use cases for this. I tend to try to be IDE-agnostic. Coding a whole project from scratch, I'd use an IDE. To just troubleshoot and test out a few cases, I'd happily bring up vim, add in a few logging statements and use the tools that maven gives me.
feicipet
+10  A: 

See the maven exec plugin. You can run Java classes using:

mvn exec:java -Dexec.mainClass="com.example.Main" [-Dexec.args="argument1"] ...
Robert Munteanu
A: 

give a try to maven exec plugin

dfa