Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problems in making an executable jar file thru Maven

 
Ankit V Agrawal
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 :-?

 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ankit V Agrawal
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Peter, that was exactly the problem. I followed what you mentioned and the problem is resolved. Thank you so much !
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic