Sometimes there is no IDE or write java program on linux, but also need maven support, often previously been copied pom.xml existing projects coming changes. But if you want to create from scratch a maven direct support of java program how to do it? You can use maven archetype, as long as there is java and maven installed on your machine you can easily create a maven java program supported:
For previous
java -version
with
mvn -v
Verify java and maven are installed correctly, then
mvn archtype:generate
Which will prompt asks you to use a archetype template, you can directly select a default maven-archetype-quickstart, it is one of the most common java procedure. Several key parameters of the program and then will create new problems, such as groupid, artifactid, version and so on.
If you do not want to create this interactive way, it is also possible to fill in all the necessary parameters with a single command, called batch mode:
mvn archetype:generate -B -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.4 -DgroupId=com.example -DartifactId=test-archetype -Dversion=1.0-SNAPSHOT -Dpackage=com.example