Reputation: 253
I have a simple java main class and can execute it using the below command on server java com.....MainClass
Now we are trying to use Maven in our application.
I am seeing on web that the maven command to execute java program is mvn exec:java -Dexec.mainClass=com......MainClass
Can I still use regular java command or do I have to use the maven command exec:java?
It's not clear to me when to use the maven exec:java command.
Please help me understand when to use regular java command and when to use the maven exec:java command. when I use Maven can I still execute program using regular java command.
Upvotes: 0
Views: 78
Reputation: 82
maven is mainly a dependency mangement and a build tool.
u can still use java command to run your main class from the jar generated by maven under the target folder of your project.
java -cp "yourProject/target/folder-containing-dependenc-jars-if-exist/*:yourProject/target/thejar.jar" package.mainClass
ps: use the ":" separator on linux system , if you are under windows use ";"
Upvotes: 1
Reputation: 2687
According to https://maven.apache.org/what-is-maven.html Maven's objectives are
So, you should use Maven for building your project... like building a JAR package with main class.
See this answer or this Oracle's tutorial for running a JAR packaged Java class.
You can also use Maven for running the main class but you should not make your production environment depended on Maven.
Upvotes: 1