Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Jar file including ONLY what it really needs

Status
Not open for further replies.

arnwald

Programmer
Jun 11, 2001
8
VE
I have created an applet using JMF (Java Media Framework) and I would like to pack my applet plus ONLY those JMF classes my applet needs into a single .jar file. How can I determine what JMF classes have to be included in the Jar?. This is because the client may not have JMF installed preventing the applet to run. I tested the applet using a jar file containing the whole JMF (2MB) plus my applet (only 11KB) on a client where JMF is not installed and it worked Ok. However 2MB for an applet is absurd. I know that my applet uses only a few JMF classes but I don't know about all dependencies for those classes. If I could determine what are those, I would be able to pack my applet with all JMF dependencies into a single jar file which would be absolutely not 2MB in size. Any tool capable of doing this, or any procedure, or any tip is appreciated. My platform is Win2K.
 
Determining these dependencies will be a very manual process unless you use a tool. Most IDEs currently support this type of operation and ANT will have a full Dependency Analyzer up and running soon (it is part of 1.5 went is stilll in BETA). To get dependencies like this to work in ANT 1.4 you will need to download a third-party extentsion, there are a few to choose from.

ANT or an IDE is the way to go here.
 
Thank you wushutwist for your tip!

I generated a jar file using JBuilder 6 Enterprise Edition and it is 432KB but it doesn't work. I don't know exactly what criteria used JBuilder to select what was included on the jar file. It certainly exclude a lot of classes but when I run the applet on a browser it crashes, although it works when I use the 2MB jar.

In JBuilder, I created first an archive builder choosing to include only required classes and known resources. Obviously I didn't add any class by hand because that's exactly what I want to determine. My applet doesn't need any resource file. Then, when I build my project it generates a jar file accordingly (using the archive builder I previously created) and it is only 432 KB. Two things about this. First, I would expect the jar to be even smaller considering the number of JMF classes that the applet needs, and second it crashes the browser.
 
My two comments.

1) Just because your class may only use a couple of JMF classes doesn't mean those classes in turn do not have 100s of other dependencies.

2) Can't explain why are program crashes without alot of other details. Do you have any errors being thrown in the console?
 
I found another freeware tool (Dietolog) which worked Ok and detects all dependencies, but still, my jar file doesn't work. I think I'll have to go for another solution as apparently the problem has to deal with JMF. I think there is some sort of "hidden" dependencies that are simply impossible to track unless we could have the ENTIRE source code and a lot of time to analyze it by hand.

DashO Pro appears to be a very sophisticated tool but I cannot afford the price tag (around $1700) at this time. That's why my tools are JBuilder EE 6 (which I already have) or freeware tools.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top