Now, assuming you have finished coding your Java project and compiled the same, it is time to create a JAR file.
The first step for creating JAR file is to ensure cleansing any previous build artifacts before packaging them as a Maven project. This can be done using mvn clean
which removes all the previously generated files from ./target folder.
mvn package
would create a new package at ./target folder.
Alternately, we could combine cleaning and package creation as one step by typing mvn clean package
. You would get a new JAR file created.