Java SE: Create Maven Project
Maven and Java
1 Create Maven Project
To create a Maven project with a standard directory structure using IntelliJ IDEA, you can follow these steps:
- Install the Maven plugin in IntelliJ IDEA.
- Open IntelliJ IDEA and navigate to the
Pluginssettings. - Search for
Mavenand install the plugin.
- Open IntelliJ IDEA and navigate to the
- In IntelliJ IDEA, click
Create New Project.- In the
New Projectdialog, selectMaven Archetypefrom the list of Generators. - Select the
maven-archetype-quickstartarchetype. This archetype creates a standard Maven project with a directory structure for source code and unit tests. - Remember to use
apachearchetype (template).
- In the
- Choose from system or download the JDK to use
- Click
Advanced Settingsand enter theGroupIdandArtifactIdfor your project. These are used to identify your project uniquely across all projects. - Click
Createto create the project.
Catalog
specify which Maven repository you want to use in your project.
The internal Maven catalog is a default one. You can also select the local repository that is located in the .m2 directory, or you can select Maven central repository.
Your project will be created with the following directory structure:
my-project
├── pom.xml
└── src
├── main
│ └── Person.java
│ Account.java
│ AccountManager.java
└── test
└── AccountManagerTest.java
The src/main/java directory is where you should put your Java source code, and the src/test/java directory is where you should put your unit tests.
To specify the version of Maven to use, you can edit the pom.xml file and add a <version> element to the <project> element. For example:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>my-project</artifactId>
<version>3.6.3</version>
...
</project>This will use version 3.6.3 of Maven for the project.
2 Step-by-step screenshots
2022-12-14
Slider-presentation Create project Java SE Maven
2024-01-14
IntelliJ IDEA 2023.3.2 (Community Edition)
Build #IC-233.13135.103, built on December 20, 2023 Runtime version: 17.0.9+7-b1087.9 amd64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o. Linux 5.15.0-91-generic
3 Idea configurations
4 What did we create?
This Java code defines a class named “HelloWorld” with a main method. When executed, it prints “Hello World!” to the console using the System.out.println statement.
The main method serves as the entry point for the program.
This simple program is a common introductory example, demonstrating the basic structure of a Java application and how to output text to the console.







