JavaGian java tutorial and java interview question and answer

JavaGian , Free Online Tutorials, JavaGian provides tutorials and interview questions of all technology like java tutorial, android, java frameworks, javascript, ajax, core java, sql, python, php, c language etc. for beginners and professionals.

Maven Create Java Project – Interactive vs Non-interactive modes

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

1. Maven create Java project with maven non-interactive mode

In non-interactive mode, maven creates a blank java project with all default options. To create this, type below command.
Console
$ 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.
Maven create java project
You can see in step 2, that Java project created has src folder created and a default pom.xml has also been created for you.

2. Maven create Java project with maven interactive mode

In interactive 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.
Console
$ mvn archetype:generate
Lets see what steps comes in wizard:

2.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).
arche_type_generate

2.2. Filtering

It can be done by typing some part of arctetype name e.g. quickstart.
filtering_maven
You need to choose option 18 for our simple java project.

2.3. Specify achetype version

Do it as 5 (or your own), and groupId as “com.howtodoinjava”.
maven_group_id

2.4. Define artifactId

Do it by desired java project name. Now, there will be some other options and confirmations. Answer them and your project is ready.
maven_options
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 moreto create

.