aspose file tools*
The moose likes Java in General and the fly likes jar file sizes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "jar file sizes" Watch "jar file sizes" New topic
Author

jar file sizes

Rob Chung
Ranch Hand

Joined: Oct 15, 2002
Posts: 46
Hi,
I was given some java source code and a jar file which contains the corresponding classes. When I compile all the code (in IntelliJ) and jar up all classes (through ANT build script), my jar file is about 50% in size to the jar file I was given.
All the classes' size are the same as before but the jar file size is halfed. Can anyone explain the reason why and whether (and how) I should fix this?
Thanks in advance!
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Does is need to be fixed? Is the jar file not working?
There is a compression option when using the jar command. Some people choose not to compress the JAR file because it can slow down the loading process.
So it could be that the people you got the jar from did not use compression and you have??
Again, does it really need to be fixed?


GenRocket - Experts at Building Test Data
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Helium,
Please change your name to be compliant with JavaRanch's naming policy.
Your displayed name should be 2 separate names with more than 1 letter each. We really would prefer that you use your REAL name.
You can change your name: here.
Thanks,
Cindy


"JavaRanch, where the deer and the Certified play" - David O'Meara
Rob Chung
Ranch Hand

Joined: Oct 15, 2002
Posts: 46
Thanks, Gregg,
I tried to jar the files manually without compression and its about the same size.
Our system has been developed in another country and I am taking over and continue the development. I have the jar and the source but I want to be absolutely sure that they match up.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Well, without knowing too much about what you do and what is required by your employer, I still wouldn't worry too much about the JAR file size matching exactly. There are a lot of things that can make a difference. One of course being the compression, and another is your original class file size. See, some IDE's include their own header information when compiling a class file. Which could increase the size. You can also supply an optimize tag when compiling that increase class file size as well. Also, I have noticed that when I compile my java files over and over and over and over....they continue to increase in size (not much mind you), then if I delete the class file and recompile the same code, the class file is smaller. I don't know why. Anyway, to make a long story short, if the JAR file works, then that seems good enough to me.
Rob Chung
Ranch Hand

Joined: Oct 15, 2002
Posts: 46
Thanks again!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jar file sizes