• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown
Bartenders:

How do you create a fat jar?

 
Ranch Hand
Posts: 279
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A fat jar just includes all the dependant classes in the jar file.
I need the fat jar because I'm deploying the application as an exe via Launch4J.
When I move the exe to a different directory then it won't without the dependant classes being present.

My problem is I'm a bit of a dinosaur when it comes to java in that I don't use IDE's etc.
The commands I use to build my game and run it are:

How do I change this so the jar becomes a fat jar?

Many thanks

Mike
 
Marshal
Posts: 77168
370
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there anything useful in the Java™ Tutorials? Try the section about creating a .jar file.
 
Bartender
Posts: 7488
171
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try http://one-jar.sourceforge.net/
 
author & internet detective
Posts: 41502
881
Eclipse IDE VI Editor Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Many people use a build tool like the Maven shade plugin to create an uber jar

Tim:: Does one-ar work without Ant/Maven
 
Rancher
Posts: 4904
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

bit of a dinosaur when it comes to java in that I don't use IDE's etc.


To do it manually:  extract the jar files into folders and then include those folders in the jar command.
 
Mich Robinson
Ranch Hand
Posts: 279
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the replies. The manuals are useful when you know what you're looking for but personally I just don't know. I don't use maven etc but one of these days I might work it out. The post about the jars made me wonder what would happen if I just put the jar files in a zip along with the exe. This seemed to work when I created a new directory for the program but unfortunately it didn't work when a friend downloaded the zip, extracted it and tried to run it. It unpacked ok but nothing happened when they clicked the exe. If I did the same on my PC it runs fine. The exe was created by launch4j and is supposed to include its own java run time etc. I have to admit this is a little infuriating.

Any other suggestions for generating an exe program that people can just run? The game plays fine but my goal is to put the program on Steam and have it loaded (and run) from there.
 
Norm Radder
Rancher
Posts: 4904
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you try what I suggested?  The resulting jar file would have your classes and the classes from all the other jar files.
I don't know anything about creating .exe files from a jar file.
 
Tim Moores
Bartender
Posts: 7488
171
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If an unpacking step is acceptable I don't understand the point of a fat jar. You can simply create a zip with all jar files, unpack it, and double click the main jar file. The others can be referenced via that jar file's manifest.
 
Tim Moores
Bartender
Posts: 7488
171
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jeanne Boyarsky wrote:Does one-jar work without Ant/Maven?


It does, and the process is described on its home page.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic