Thursday, November 20, 2014

Maven: add plugin to pom configuration for Maven to build a jar package in Eclipse and STS

To use maven to compile and build a jar package, create a maven project in Eclipse or STS. After the project is created add the following xml sections to the end of the pom.xml file in the project.



<mainClass />



After the implementation of java coding. To build and run using maven, navigate to the project folder in the terminal and run the following command:

> mvn compile exec:java -Dexec.classpathScope=compile -Dexec.mainClass=[mainClassFullPath]

where [mainClassFullPath] refers to the full name of the class containing the main() method.


> mvn clean install