This tutorial shows how to convert the current Java project to a maven project opened in Intelli IDEA.

We can create new Java, maven, or Kotlin projects directly or can import existing applications into IntelliJ IDEA.

The Maven project contains dependency configuration in pom.xml.

You can manually convert the Java project to a Maven project using the below steps

  • Add the pom.xml to the java project root folder.
  • It is very difficult to add dependencies without color syntax

IntelliJ IDEA provides inbuilt support from normal Java projects into the maven project creates pom.xml and moves the folders and support for adding dependencies.

How to convert Java project to maven project in Intelli IDEA editor.

  • Open Java project in Intelli IDEA
  • right-click on the project, It shows the context menu
  • Select Add to Framework Support options
  • It opens the Add to Framework Support window
  • Select and check Maven in this window.

You can see both of the above steps in the below window.

Intellij convert java to maven project

  • It adds pom.xml with default values.
  <?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>groupId</groupId>
    <artifactId>javacode</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
    </properties>

</project>
  • You can change the groupid, artifactId, and version manually.
  • Also, add dependencies manually.

Similarly, This is another way of converting a Java project to a Maven project.

Select File > New > Project from Existing Sources and follow the steps to give groupid, artifactId, and version details