Maven – Create Java Project with Non/Interactive Mode

Learn to create a Java application project with maven, using interactive and non-interactive modes from the command prompt.

1. Using Maven Non-interactive Mode

In non-interactive mode, Maven creates a blank Java project with all default options applicable for the selected Maven template. To create this, type the below command.

//Remove the new line characters. This command should be in a single line.

$ 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 the workspace. You can choose and use your own application name. We can see what happens when you run the above command in the below image.

maven-create-java-project-4223005

We can see in step 2, that the Java project has standard folders created and a default pom.xml has also been created in the project root.

2. Using Maven Interactive Mode

In interactive mode, We just need to start with “mvn archetype:generate” and the rest of the options will be specified using a wizard which will come one by one.

$ mvn archetype:generate
arche_type_generate-8257782

The wizard stops at where it will ask for archetypeArtifactId. Wizard will present us a list of numbers to choose from or filter among them (because the options list is very long).

filtering_maven-7183266

We need to choose option 18 for our simple java project.

Finally, choose the archetype version as 5 (or any other of your choice), and groupId as “com.howtodoinjava“.

maven_group_id-2551424

Finally, choose the artifactId that is the desired project name. Now, there will be some other options and confirmations. Answer them, and our project is ready.

maven_options-8813301

We can see that our project is created with the default source folder and pom.xml file.

Happy Learning !!

Leave a Reply

3 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments

About Us

HowToDoInJava provides tutorials and how-to guides on Java and related technologies.

It also shares the best practices, algorithms & solutions, and frequently asked interview questions.

Our Blogs

REST API Tutorial