This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of Darcy DeClute's Scrum Master Certification Guide: The Definitive Resource for Passing the CSM and PSM Exams and have Darcy DeClute on-line!
See this thread for details.
  • 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
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

How do you create a fat jar?

 
Ranch Hand
Posts: 287
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: 78700
374
  • 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.
 
Saloon Keeper
Posts: 7552
176
  • 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: 41775
887
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: 5008
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: 287
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: 5008
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
Saloon Keeper
Posts: 7552
176
  • 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
Saloon Keeper
Posts: 7552
176
  • 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.
 
If you try to please everybody, your progress is limited by the noisiest fool. And this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic