Solved

Use jar of a jar for your classpath

Posted on 2002-04-25
9
221 Views
Last Modified: 2013-11-23
Hi!
I want to reduce the size of my zip file (a.zip) that contains my classes (1,130 KB).
I've noticed that if I create a new zip file (b.zip) that contains the old zip file (a.zip) then the size of b.zip becomes 1,000 KB !
The problem is that I can't put b.zip in the classpath instead of a.zip and expect java to get the classes from it.

Can you tell me how can I use b.zip?
Thanks!!!
0
Comment
Question by:rzvika2
9 Comments
 
LVL 35

Expert Comment

by:girionis
ID: 6967980
 If you create a b.zip file that contains the a.zip file and some additional classes then you can use it in your classpath. The only thing is that the JVM will not be able to read the classes from the a.zip file but only the ones from the b.zip. If you want to use both files then you will have to have two separate .zip files in your classpath.

  Hope it helps.
0
 
LVL 9

Expert Comment

by:Venci75
ID: 6967997
I don't think it is possible. At least you should create your own class loader.
How do you create your zip file? - using WinZip?
I am asking because may be there is another way to reduce the size of your zip file
0
 
LVL 92

Expert Comment

by:objects
ID: 6968059
Did you use the same compression for creating a and b?
0
 

Author Comment

by:rzvika2
ID: 6968097
Venci75: yes, can you tell me about a more powerfull compression tool?
objects: yes, the maximum compression.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 16

Expert Comment

by:heyhey_
ID: 6968299
I would suggest you to use obfuscator
0
 

Author Comment

by:rzvika2
ID: 6968712
Can you tell me some more info (whre to get it, compression relates to winzip...)
Thanks!
0
 

Author Comment

by:rzvika2
ID: 6968726
BTW, in case it compress the code like Dashopro, we already use Dashopro.
We want to compress more than that...
0
 
LVL 92

Expert Comment

by:objects
ID: 6969889
As others have mentioned there is no easy way to use a jar in a jar. And if you develop one, then the extra class will eat up the minor saving you achieve doing this.
If you want to reduce the size of your jar then I'd suggest looking at your code, and trying to optimise the size of your class files.
0
 
LVL 1

Accepted Solution

by:
iartmirko earned 200 total points
ID: 6971051
Hi rzvika,

if you need to reduce the size of your zip/jar file you don't have to zip it twice. There is a nice (FREE!) tool from IBM alphaWorks that solves your problem of big jars by doing the following:
- Removal of dead methods and fields
- Detection of live overridden methods
- Removal of unused classes and interfaces
- Inlining of methods
- Removal of non-essential attributes
- Shortening of internal method names and field names
- Removal of non-used entries in the constant pool

After the above steps, JAX may use more aggressive compression techniques as well.

See http://www.alphaworks.ibm.com/tech/jax for downloads and details...

Hope taht will solve your problem.

Mirko
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
mapAB Challlenge 35 126
@SBGen Method 3 37
compre toata in where clue oracle 4 56
How to monitor the number of connections/threads being utilized on Tomcat 6.0 8 56
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now