Refresh the Maven project in the Maven Projects tool window (Reimport All Maven Projects), if it doesn't help, refer to this answer for diagnostics.

The issue is that your source roots were not configured correctly from the Maven model for some reason and the .java file appears in a plain directory instead of the Source root.

You can tell that by the color of the folders and by the icon of the file.

Answer from CrazyCoder on Stack Overflow
🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 360010630320-How-to-run-Java-project-with-Maven
How to run Java project with Maven? – IDEs Support (IntelliJ Platform) | JetBrains
April 3, 2021 - --module ...". What should I specify in the Run/Debug Configuration or Maven Plugin/Lifecycle to run/debug the application from IntelliJ? ... You can create a plain Application run configuration and configure it according to your needs. After that, the configuration will be available in the corresponding drop-down on the Navigation bar so that you can run/debug your app quickly. You can also use a Maven run configuration.
Discussions

How to run using terminal on IntelliJ Idea using Maven? - Stack Overflow
Open a shell/terminal tool window in idea and run mvn test. You might need the bash plugin installed. ... Hi @bmargulies, Yup already see that terminal, but I don't know what to write on those. I'm not really a coder type since I'm a manual tester. ... If it is a maven project, go to the terminal(Alt+F12 in intellij... More on stackoverflow.com
🌐 stackoverflow.com
java - How to execute mvn command using IntelliJ IDEA? - Stack Overflow
I am trying to add Oracle JDBC driver in my local Maven repo. I have found this link to do so. I want to do the same from Inside IntelliJ IDEA. Is there any way to execute mvn commands from IntelliJ More on stackoverflow.com
🌐 stackoverflow.com
Document says to build the project using maven command: mvn clean install (how do I do this?)
Assuming maven is installed, you should be in the project directory. Maven will look for a pom.xml file. More on reddit.com
🌐 r/IntelliJIDEA
5
3
May 5, 2022
[help] Running IntelliJ on Windows while building in WSL
symlink your source directory within WSL. If your source directory is C:\Java\Source\myproject symlink it like so ln -s /mnt/c/Java/Source/myproject ./myproject or something similar. From there, you have full, easy access to the files in both Windows and WSL. The link isn't needed, you could also just cd /mnt/c/Java/Source/myproject and work from there More on reddit.com
🌐 r/bashonubuntuonwindows
6
7
February 9, 2018
🌐
Reddit
reddit.com › r/intellijidea › document says to build the project using maven command: mvn clean install (how do i do this?)
r/IntelliJIDEA on Reddit: Document says to build the project using maven command: mvn clean install (how do I do this?)
May 5, 2022 -

Where do I build the project using the maven command? I'm assuming this is the terminal bottom tab? But it's not in a build section.. hmm. Any help is appreciated, thank you!

🌐
JetBrains
jetbrains.com › help › idea › run-debug-configuration-maven.html
Run/Debug Configuration: Maven | IntelliJ IDEA Documentation
You can run Maven goals using run configuration. The default options listed in such a configuration are enough to run your task.
🌐
HowToDoInJava
howtodoinjava.com › home › maven › guide to maven projects in intellij ide
Guide to Maven Projects in IntelliJ IDE
July 11, 2023 - It compiles the source code of the project. ... We can run the command from the IDE also by navigating to: Right-click on the project root in the Project tool window, go to “Maven,” and select “Compile.”
🌐
Stack Overflow
stackoverflow.com › questions › 55997917 › how-to-run-using-terminal-on-intellij-idea-using-maven
How to run using terminal on IntelliJ Idea using Maven? - Stack Overflow
IntelliJ-IDEA actually has a built-in terminal that you can run maven commands in at a project level. Simply click the "terminal" button on the very bottom bar. If you don't see it, try "Alt+F12".
🌐
JetBrains
jetbrains.com › help › idea › delegate-build-and-run-actions-to-maven.html
Maven projects | IntelliJ IDEA Documentation
On the Runner page, select Delegate IDE build/run actions to Maven. ... In the main menu, go to Build | Build Project Ctrl+F9. IntelliJ IDEA invokes the appropriate Maven goals.
Find elsewhere
🌐
YouTube
youtube.com › aj automation
How to Run Maven Project in IntelliJ Idea [ Different ways ] 2023 Session | #intellij #maven - YouTube
▶️ In this session we will learn how to run Maven Project in IntelliJ Idea.▶️ There are different ways to run Maven Project.▶️ Using Terminal , Maven Tool Se...
Published   February 19, 2023
Views   15K
🌐
Medium
iamvickyav.medium.com › open-maven-gradle-projects-in-intellij-with-command-line-474696437e26
Open Maven/Gradle projects in IntelliJ using Terminal - Vicky AV
September 10, 2020 - Usually we open IntelliJ & import the project from File menu. But how to do the same from your terminal ? ... Choose the name & where the script has to get created. In above image, idea is the script name ... > cd <SOURCE_CODE_FOLDER>// If the project is Maven> idea pom.xml// If the project is Gradle> idea build.gradle
🌐
JetBrains
blog.jetbrains.com › home › intellij idea › maven and intellij idea
Maven and IntelliJ IDEA - The JetBrains Blog
July 28, 2021 - For example, if you are using IntelliJ IDEA’s built-in terminal window to execute the Maven command ‘maven clean verify’, you just need to hit Ctrl+Enter (or Cmd+Enter) and IntelliJ IDEA will execute the command.
🌐
YouTube
youtube.com › watch
How to Create and Run a Maven Java Project in IntelliJ - YouTube
In this IntelliJ tutorial, learn how create and run a Maven Java project. This takes you through the setup wizard as well as shows you all the files generate...
Published   September 20, 2024
🌐
QA Automation Expert
qaautomation.expert › 2021 › 04 › 29 › how-to-create-a-java-maven-project-using-command-line-in-intellij
How to create a Java Maven project using Command Line in IntelliJ – QA Automation Expert
April 29, 2021 - A) Value of groupId – This serves as the group identifier of your Maven project, it should be in a form similar to Java packages, such as com.example B) Value of artifactId – This serves as the group-local identifier of my Maven project like MavenIntelliJFromCMD C) Value of Version – The initial version of our project. The default is 1.0-SNAPSHOT D) Value of package – The name of our root package. The default is groupId we have created earlier. We will notice the INFO message about the properties. If the displayed settings are correct, then just enter Y in :: prompt. Step 7 – Successful Build – Below screenshot shows that the Maven IntelliJ Project built successfully.
🌐
JetBrains
jetbrains.com › help › idea › maven-projects-tool-window.html
Maven tool window | IntelliJ IDEA Documentation
September 17, 2025 - Use the Maven tool window to view the available Maven projects, download sources and Javadocs, and execute phases of the build lifecycle. The tool window displays nodes for each Maven project, with the Lifecycle, Plugins subnodes.
🌐
IronPDF
ironpdf.com › ironpdf for java › blog › using ironpdf for java › intellij maven
Working with Maven Projects in IntelliJ | IronPDF for Java
April 22, 2026 - Right-click on it and navigate to Run > Main. This action will start the execution of your project. Note: The option Main can vary based on your project setup. It refers to the main class serving as the entry point of your application.
🌐
Davidvlijmincx
davidvlijmincx.com › home › intellij › use maven to build and run your project in intellij idea
Use Maven to Build and run your project in IntelliJ IDEA
May 31, 2023 - To force IntelliJ to use Maven for Run and Build, you have to select a single checkbox, which is quite well hidden inside the menu options. You can find this setting under: File -> Settings -> Build, Execution, Deployment -> Build tools -> Maven -> Runner.
🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 4409701015954-Unable-to-run-maven-in-intellij-terminal
Unable to run maven in intellij terminal – IDEs Support (IntelliJ Platform) | JetBrains
"The JAVA_HOME environment variable is not defined correctly This environment variable is needed to run this program NB: JAVA_HOME should point to a JDK not a JRE" I have JAVA_HOME defined(H:\jdk\11x64-latest\bin), that is why intellij and another ide i have is working. I am using lastest version and it doesnot have a separate JRE. So line 3 in the message is ruled out. Please advise · Please advise. ... H:\jdk\11x64-latest\bin is not a valid JAVA_HOME. JAVA_HOME points to the JDK installation location without bin subdirectory. IntelliJ IDEA works without JAVA_HOME just fine, it doesn't use it.
🌐
YouTube
youtube.com › automation step by step
IntelliJ IDEA Beginner Tutorial | How to create Maven Project - YouTube
After watching take this Quiz - https://automationstepbystep.com/2021/08/17/maven-quiz/All FREE courses - https://automationstepbystep.com/Today we will lear...
Published   August 17, 2021
Views   154K
🌐
TutorialsPoint
tutorialspoint.com › maven › maven_intellij_idea.htm
Maven - IntelliJ IDEA IDE Integration
You can run Maven goals from IntelliJ IDEA. You can view the output of Maven commands inside the IntelliJ IDEA using its own console. You can update maven dependencies within IDE. You can Launch Maven builds from within IntelliJ IDEA. IntelliJ IDEA does the dependency management automatically based on Maven's pom.xml. IntelliJ IDEA resolves Maven dependencies from its workspace without installing to local Maven repository (requires dependency project be in same workspace).
🌐
GeeksforGeeks
geeksforgeeks.org › java › how-to-create-a-maven-project-in-intellij-idea
Creating a Maven Project in IntelliJ IDEA - GeeksforGeeks
IntelliJ IDEA is an integrated development environment (IDE) written in Java and developed by JetBrains. It is widely used for developing computer software. We will see the steps to create a Maven project in IntelliJ IDEA, from initial project setup to managing dependencies, building your project, and running tests.
Published   January 9, 2026