Maven ramblings

candidStoryTeller
2 min readApr 19, 2020

Creating new java projects in Intellij

I work at a fintech startup in India. Interviewing people is a day-to-day job like for many others at a mid-seniority or above level.

One of these rounds involves asking people to code a real-world problem in 1.5 hours. The code needs to be runnable, with test cases and should look clean, commented and neatly structured.

When people ask me how to prepare for this round, the first advice I give them always, is to keep your IntelliJ setup ready for a new project.

And, this is because 1 out of 2 guys I interview, doesn’t know how to build a new java project and import it to Intellij. So, many a times they end up writing code, which is not runnable, simply because they don’t know how to import dependencies into POM, how to run a application in Intellij.

This is also the reason, why many people don’t start writing something new, they simply don’t know how to start!

Now if you want to start a new java project in a IDE like Intellij you will need following things:

  • JDK installed, maven cli installed, Intellij Community edition installed
  • create a new maven project on cli
  • Open intellij and import this project using the option ‘Project from existing sources’

And you are ready…

It is that simple.

So, I will mention the small bits to complete this setup.

About Maven and how to create new project

Maven is a commandline tool to create and manage java projects. The core artifact in maven is a POM file. Full form of POM is Project-object model

This file lists-

  • naming and versioning of the project,
  • all its dependencies
  • How to build this project — which targets to build

Following is one command

mvn archetype:generate
-DgroupId=com.company.myapp -DartifactId=myapp -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.4 -DinteractiveMode=false

Maven uses archetype plugin to create projects, the particular archetype artifact we have used here is maven-archetype-quickstart, there are other archetypes specifically meant to create web-apps, or other types of maven projects.

Once you have created this empty maven project, you can

  • open Intellij
  • choose ‘Import project’ -> Maven

And you are done. When you open your Intellij project, you can see a neat directory structure like this-

my-app
|-- pom.xml
`-- src
|-- main
| `-- java
| `-- com
| `-- mycompany
| `-- app
| `-- App.java
`-- test
`-- java
`-- com
`-- mycompany
`-- app
`-- AppTest.java

Happy coding!

What does project, modules mean in maven(WIP)

What is parent pom?

Sign up to discover human stories that deepen your understanding of the world.

candidStoryTeller
candidStoryTeller

No responses yet

Write a response