Maven is a build and dependency management tool for java based application development. In previous post, we learned about installing maven on windows operating system. In this post, I will write about creating a simple java project.
Sections in this post: Using non-interactive mode Using interactive mode
Using non-interactive mode
In non-interactive mode, maven creates a blank java project with all default options. To create this, type below command.
mvn archetype:generate -DgroupId=com.howtodoinjava -DartifactId=DemoJavaProject -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
This command will create a blank java project named DemoJavaProject in workspace. You can choose and use your own application name.
In below image, you can see what all happens when you run above command.
Using interactive mode
In this mode, You just need to start with “mvn archetype:generate” and rest of the options will be specified using a wizard which will come one by one.
Lets see what steps comes in wizard:
1) mvn archetype:generate
This is default mode. When you type above command, it start the project creation and will stop at where it will ask for archetypeArtifactId. Wizard will present you a list of number to choose from or filter among them (because options list is very long).
2) Filtering can be done by typing some part of arctetype name e.g. quickstart.
You need to choose option 18 for our simple java project.
3) Specify achetype version as 5 (or your own), and group id as “com.howtodoinjava”.
4) Define artifactId by desired java project name. Now, there will be some other options and confirmations. Answer them and your project is ready.
You can see that you project is created with default source folder and pom.xml file.
This way, if you try your hands a couple of times, you will start liking this approach more.
Happy Learning !!