This week's book giveaway is in the Open Source forum.
We're giving away four copies of Programmers Guide to Apache Thrift and have Randy Abernethy on-line!
See this thread for details.
Win a copy of Programmers Guide to Apache Thrift this week in the Open Source forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Maven: Create Runnable Jar with Dependency Jar Files (Fat Jar)  RSS feed

 
Saloon Keeper
Posts: 2566
323
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is my first attempting at building with Maven (previously I have always used Ant).

I am trying to assemble a runnable jar file which includes the dependent jar files for netty, kafka, etc.  I am able to build without any errors, but when I try and run by jar, I find that the jars for the dependencies were not bundled in the jar which was built.  

Any hints to help me sort this out?  I'm sure hoping that it is something simple.

My pom.xml:
Console output from build:
 
Bartender
Posts: 2277
95
Eclipse IDE Google Web Toolkit Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not much sure about this since I haven't done it, but I think this might help : https://www.mkyong.com/maven/create-a-fat-jar-file-maven-assembly-plugin/
Most of my maven builds are thin jars with dependencies deployed separately and not a far jar as your problem is stated.
 
Ron McLeod
Saloon Keeper
Posts: 2566
323
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Following the advice from this StackOverflow thread and this other StackOverflow thread, I was able to create the runnable fat jar I wanted using the Apache Maven Assembly Plugin


 
Ron McLeod
Saloon Keeper
Posts: 2566
323
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

salvin francis wrote:I am not much sure about this since I haven't done it, but I think this might help : https://www.mkyong.com/maven/create-a-fat-jar-file-maven-assembly-plugin/

Thanks for the link It looks like ti is also using the assembly plug-in.
 
salvin francis
Bartender
Posts: 2277
95
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Happy to help . The reason why you found it difficult was that it is not a common scenario to build a fat jar in maven. Even if you want to run it as a standalone jar, maybe you can consider including dependencies in classpath instead of bundling them ?
 
Sheriff
Posts: 21741
102
Chrome Eclipse IDE Java Spring Ubuntu VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I prefer the shade plugin over the assembly plugin for fat JARs. I've also used the One Jar maven plugin but that creates a fat JAR with the dependencies included as JAR files with a custom class loader.
 
I'm a lumberjack and I'm okay, I sleep all night and work all day. Lumberjack ad:
ScroogeXHTML - small and flexible RTF to HTML converter library
https://coderanch.com/t/710903/ScroogeXHTML-RTF-HTML-XHTML-converter
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!