Win a copy of Event Streams in Action this week in the Java in General 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
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

How do you create a fat jar?

 
Ranch Hand
Posts: 273
2
  • Mark post as helpful
  • send pies
  • 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: 65037
247
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there anything useful in the Java™ Tutorials? Try the section about creating a .jar file.
 
Saloon Keeper
Posts: 5707
144
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try http://one-jar.sourceforge.net/
 
author & internet detective
Posts: 39392
763
Eclipse IDE VI Editor Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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: 3409
33
  • Mark post as helpful
  • send pies
  • 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: 273
2
  • Mark post as helpful
  • send pies
  • 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: 3409
33
  • Mark post as helpful
  • send pies
  • 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: 5707
144
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • 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: 5707
144
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • 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.
 
mooooooo ..... tiny ad ....
Java Code Review and Psychology
https://coderanch.com/t/714798/java/Java-Code-Review-Psychology
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!