"Javing" is the present continuous form of "to program in Java".
Here you will find: code snippets, examples, tips, tricks, tutorials, best practices, miscellaneous and much more.
Enjoy your Javing!

Friday, June 20, 2014

Creating an executable jar file with maven

It happen to me recently that I wanted to pack a little app with maven and run it from the console, butI always forget what is the config that I need to add to maven in order to make sure the manifest pointing to the class with the main method is included.

After wasting precious half hour around the internet and after I did what I wanted to do, I thought... What better place to write this config once and remember it forever, than my blog ;)

To do it just add the following to your pom.xml and make sure you write the correct path to your main class.

When the maven package gets executed two .jar files will be created.
The one with the text jar-with-dependencies on its name, will contain is the one we should run. To do it, just go to the terminal, navigate to it(inside the target folder) and type the command:

Contact me

Name

Email
*

Message
*

About javing

I want to welcome you to my blog.My name is Djordje Popovic, I am a Software Craftsman and an enthusiast of the java programming language.

In 2011 I decided to create javing just as a way to keep track of my studies on the java programming language and also provide support to other fellow students. This blog has being here since the beginning of my career as a programmer. Fell free to make comments or critics to my entries, ill be happy to read them and answer to you.