Skip to main content

Maven how to set the Main-Class in the Manifest

In Java, for a jar to be executed, the easiest way is to set its entry point. This is done by setting the Main-Class in the Manifest. Easy.
Now let's do it with Maven !

First you use your jar, in Maven, you can to configure it this way:
project/build/plugins/plugin
artifactId maven-jar-plugin
version 2.2
configuration
archive
manifestEntries
Main-Class com.comp.proj.main

Now you would like your jar to contain all the dependencies, then you use the maven-assembly-plugin. But it won't take the configuration set in the jar plugin. You have to reconfigure the exact same main-class again. It is redundant OK, but why should it have a different syntax !?!
project/build/plugins/plugin
artifactId maven-assembly-plugin
configuration
archive
manifest
mainClass com.corial.cosma.apptest.apptest

OK, the point is that there are at least two way to configure the Manifest. Either with a free key/value syntax, with Manifest Entries. Or with the class Manifest which has a mainClass element. So it is up to you to be consistent in your POM and not copy everything found on the net ...

Notes:

Comments

Popular posts from this blog

VirtualBox, CentOS, Network and Template

I have been working with VirtualBox and CentOS recently, here are some notes about this experience.
I used VirtualBox 4.2 and CentOS 6.3, but most of this should work with other products too. I created the first headless, minimal CentOS via NetInstall.
I cover two points: create a template machine and configure the Network.
Configure the NetworkWe want Internet access and a LAN local to the host.
For background information read: Networking in VirtualBox by Fat Bloke on June 2012.
The easiest is to enable two Network Adapters: One will be "Host-only" and the second "Nat". In the "Preference" menu you can see the DHCP server range for the Host-only Network. So you may set fixed addresses outside this range.
Next: start the guest. There may be various results at first, depending on a lot of things. Some problem might be solved by rm -f /etc/udev/rules.d/70-persistent-net.rules and a reboot.
Anyway, configure the two interfaces (set your own IP and MAC addresses)…

One in six IT projects ends up ‘out of control’

http://www.ox.ac.uk/media/news_stories/2011/110822_1.html

A surprisingly high number of projects are 'ticking time bombs', according to researchers at the University of Oxford. They analysed 1,500 global projects that had revamped their information technology systems within the last 10 years. They discovered that one in six projects in the sample went over budget by an average of 200 per cent (in real terms) or over ran by an average of almost 70 per cent.

Their conclusion is similar to previous studies: http://brunovernay.blogspot.com/2009/10/excellent-studies-on-software-quality.html