Maven command to run a Java main class

There might be more than one Java classes in a Maven project that contains the main() function. To pick up a specific one to run, you can try the following command:

[sourcecode]
mvn exec:java -Dexec.mainClass="my_main_class_name"
[/sourcecode]

In case the memory is not enough, try the following command:

[sourcecode]
export MAVEN_OPTS=-Xmx1024m
[/sourcecode]
where 1024m is the max heap memory

Leave a Reply