Home > Apache, build tools, Java, Maven, XML > How To Create A Jar File With Maven

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="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/maven-v4_0_0.xsd">



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 log4j.properties 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

Categories: Apache, build tools, Java, Maven, XML
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: