To create a maven quick start project:
mvn archetype:generate -DgroupId=com.learninjava -DartifactId=learninjava -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
To specify the 1.8 build plugin, update pom.xml with:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
RUN:
To run the java class from command prompt:
1. mvn package
2. java -cp target/my-app-1.0-SNAPSHOT.jar com.learninjava.App
To run the java class using maven - Without arguments:
1. mvn compile
2. mvn exec:java -Dexec.mainClass="com.learninjava.LambdaExpressions"
To run the java class using maven - With arguments:
1. mvn compile
2. mvn exec:java -Dexec.mainClass="com.learninjava.LambdaExpressions" -Dexec.args="arg0 arg1 arg2"
For other options see :
http://www.vineetmanohar.com/2009/11/3-ways-to-run-java-main-from-maven/
No comments:
Post a Comment