Create a maven project using command line

By | October 24, 2020

In this post, We will learn How to create a maven project using the command line

Step 1: Create a folder/directory with any name in your favorite local derive and open the command. Make sure your command prompt is pointing to that folder/directory

For Example, I have created a folder named: MyWorkspace in C drive  after that opened command prompt which is pointing to C:\MyWorkspace


Step 2:Now you to type the below command on the command prompt and press Enter

You will see the maven provides a lot of artifactId and it also shows the corresponding description. Now we have to select artifactId to create a project. Here Maven also recommends choosing artifactId 1674. if you scroll up then you can see which kind of project we can create using artifact id 1674

1674: remote -> org.apache.maven.archetypes:maven-archetype-quickstart (An archetype which contains a sample Maven project.)

Note: ArtifactId 1674 is used to create a sample maven project. If you want to create a  Web project java project or other types of java project then you need to choose the appropriate artifact id among the provided artifactId list.

Step3: Here just for this demo purpose either directly you press enter or type artifactId 1674 and press Enter

Now we have to  Choose org.apache.maven.archetypes:maven-archetype-quickstart version: as you can see in above image.

Here Maven is recommending to choose 8 so either directly you can press Enter or Type 8 and press Enter 

I have types 8 and press Enter.

After that,

You have to enter a value for groupId,artifactId, version, and package and press enter. like below

‘groupId’: com.kkjavatutorials
‘artifactId’: MyDemoProject
‘version’ 1.0-SNAPSHOT: : 1.0-SNAPSHOT
 ‘package’ com.kkjavatutorials: : com.kkjavatutorials

Finally, You have to press Y and press Enter for confirmation

If you see a message BUILD SUCCESS That means the java maven project is created successfully.

If you go to your MyWorkspace and then inside of the project(MyDemoProject) you will observe the pom.xml file is present in the project root directory that means it is a maven project.


That’s all about How to create a maven project using the command line?
If you have any feedback or suggestion please feel free to drop in below comment box.

Leave a Reply

Your email address will not be published. Required fields are marked *