GeeCON Prague 2014*
The moose likes Ant, Maven and Other Build Tools and the fly likes Problems in making an executable jar file thru Maven Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Problems in making an executable jar file thru Maven" Watch "Problems in making an executable jar file thru Maven" New topic
Author

Problems in making an executable jar file thru Maven

Ankit V Agrawal
Greenhorn

Joined: Jan 27, 2012
Posts: 12
Hello All,

I'm trying to make an executable jar file thru maven, but I'm getting this error :





Here is my pom.xml file





I have checked the contents of the Manifest file and it does seem to be correct. Please let me know if any one has any idea about whats happening :-?



SCJP 5.0, SCWCD 5.0
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5836
    
    7

You are looking at the wrong JAR file. The JAR file you are looking at is described by the JAR plugin in lines 68-79.

Your POM doesn't have any execution entry for the assembly plugin. Did you remember to pass assembly:single on the build command line? If not, the assembly plugin will not have run. If that goal does get run you will have a JAR name bls-inquiry-tracking-1.0-jar-with-dependencies.jar, that's you one you want to run.


JBoss In Action
Ankit V Agrawal
Greenhorn

Joined: Jan 27, 2012
Posts: 12
Peter, thanks for the reply. Yes I made a mistake and did not give any execution in the pom.
I have modified the pom. Now I'm getting 3 jars.

bls-inquiry-tracking-1.0-SNAPSHOT-jar-with-dependencies.jar
bls-inquiry-tracking-1.0-SNAPSHOT-sources.jar
bls-inquiry-tracking-1.0-SNAPSHOT.jar

The MF file in the 1st jar is
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: 1.5.0_12-b04 (Sun Microsystems Inc.)

And when I try to run it I get the following error :
C:\projects\bls-inquiry-tracking\target>java -jar bls-inquiry-tracking-1.0-SNAPSHOT-jar-with-dependencies.jar
Failed to load Main-Class manifest attribute from
bls-inquiry-tracking-1.0-SNAPSHOT-jar-with-dependencies.jar


The Mf file of bls-inquiry-tracking-1.0-SNAPSHOT.jar is still the same as what was in my previous post.

Here is my modified pom.xml


Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5836
    
    7

You never identified a main class for the jar-with-dependencies jar. Use the archive parameter to set that up - copy lines 76-81 to after line 89.
Ankit V Agrawal
Greenhorn

Joined: Jan 27, 2012
Posts: 12
Thank you Peter, that was exactly the problem. I followed what you mentioned and the problem is resolved. Thank you so much !
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problems in making an executable jar file thru Maven