How To Create A Jar File With Maven


This post is about how to create a java project template into jar package. Here are the tools i have used.

  1. JDK 1.6
  2. Apache maven 3
  3. Eclipse 3.7

First create a project template using maven

$ mvn archetype:generate -DgroupId=com.supun.core -DartifactId=technodyne-DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

Then convert it to eclipse project.

cd technodyne/
mvn eclipse:eclipse

import it to Eclipse. Will show as follows.

The pom.xml file should be like this.

<project xmlns="" xmlns:xsi=""



Then add the log4j dependencies for the project.

package com.supun.core;

import org.apache.log4j.Logger;

 * Hello world!
public class App

 static Logger logger = Logger.getLogger(App.class);
 public static void main( String[] args )
 System.out.println( "Hello World!" );


Then create file inside the main/resources folder

# Root logger option
log4j.rootLogger=DEBUG, stdout

# Direct log messages to stdout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n

Now run this jar as follows.


That’ s it. Happy coding ..:D


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