Starting with Maven!

This tutorial will teach you important things about Maven, a powerful program to help you to organize your project and handle your project’s dependencies.

Maven – What is

Basically Maven is a very useful program for medium/large projects written in Java that helps you in basically 2 things that are more interesting to us:

  • Project organization

  • Dependencies manipulation

We’ll talk about each of the above things soon.

Maven is practically required for big applications and big enterprises have to use that because it optimizes certain project processes.

Fortunately, today Maven comes already integrated with Eclipse, so you don’t even need to install it! Only use and be happy! =)

Project Organization

When you open Eclipse, you can create a lot of kinds of projects without using Maven. You can create a Java project, to create applications that run as Desktop programs. You can also create a Web project, which interests to us.

Web project

The Web project supports codes written in Java, HTML, CSS, Javascript… This project runs in a server, such as Tomcat and the interface appears in the browser. Ok. You can also save things in the database. Ok.

What happens is that Web project Eclipse offers to you is in fact very rudimentary. Ancient web applications written in Java were like that (called Java EE with Java Servlets). This project format left the its organization a mess. Its what we want to avoid, since we want to create a project that will be easy to understand in the future, even for your business’s new employees.

Therefore, we will create a Maven Web project, which will come with everything separated in your correct place, everything organized in its structure. We’ll see that soon.

Dependencies manipulation


A dependency is nothing more than a .jar file, which is like a Java project compressed and you can use in your own project, like a library. Let’s see an example:

Last month you created a project that raffled random numbers (any project…). Today you want to create another project, but you want to use the later platform that you implemented (about random numbers raffle) in your new code. You don’t need to put all the files from old to the new project, you can simply compress your old code in a .jar and add it to your new project. Your project will be able to instantiate your the old classes and call its methods.

And that is very important. Dependencies are nothing more than libraries. For example, to execute operations in an image, we can use some library that make images processing and for that we need to add its .jar in our project. The same thing happens with Hibernate for example, which helps handling database stuff: we need to put the Hibernate’s .jars in our project to can use that.

Where does Maven enter in this history?

Maven helps you to handle these dependencies.

These dependencies are often global and lots of people use them, like Hibernate, Spring, MySql… And those dependencies have differences about version. Downloading these dependencies often is well painful, since finding the .jars up to finding the .jars with compatible versions.

With Maven, you only need to add some lines of XML code in your pom.xml and it finds the library for you and leave it ready to use in your project.

PS.: Maven finds dependencies which are registered in its repository. So, the big enterprises put its dependencies in Maven repository. A lower library, not too known, probably won’t be in Maven repository. In that case you can’t use Maven to import that library. It has to be done manually, adding the .jar files.


Next we will learn how to create a Maven Web project in the Eclipse!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s