Thursday, January 7, 2010

Re: [Java] How to trim unneeded classes from JAR

Oliver,

Unless you have a JAR file that is several megabytes in size that needs
to be loaded every time the application is loaded (such as a JEE WAR
file, or the application is in it's own JAR file with other embedded JAR
files), I wouldn't worry about it. When an application is run, the Java
Classloaders only load the classes that are used, so if an application
only uses 10% of the classes in a JAR, then only 10% of those classes
will be loaded. This is unlike the library systems of C, C++, etc.

Even if you need to worry, as in the exceptions listed above, there are
ways around the problem.
1) If it's a JEE/J2EE application, place extremely large JAR files in
the application server's shared LIB directory. Then, applications will
only load what they need.
2) If this is a stand-alone application in it's own JAR file, explode
the JAR and adjust the classpath to reference all classes (the base of
the .class tree, plus all .jar files). Once again, this will cause the
classloader to only load what it needs.

-Java Guy


Oliver Ruebenacker wrote:
>
> Hello,
>
> I am participating in a large software project that features a large
> codebase from which multiple applications can be build. At least one
> of those application uses only a small fraction of the code, but
> finding out which classes are needed and which are not would be too
> cumbersome to track manually. Is there a tool that, given the main
> class, can trim unneeded classes? Thanks!
>
> Take care
> Oliver
>
> --
> Oliver Ruebenacker, Computational Cell Biologist
> Systems Biology Linker at Virtual Cell (http://vcell.org/sybil
> <http://vcell.org/sybil>)
> Turning Knowledge Data into Models
> Center for Cell Analysis and Modeling
> http://www.oliver.curiousworld.org <http://www.oliver.curiousworld.org>
>
>


------------------------------------

Visit http://aiaiai.com or http://jgame.org for more groups to join.
Java Official Group is created for the following topics: Java 2 Enterprise Edition - J2EE, Java 2 Standard Edition - J2SE, Java 2 Micro Edition - J2ME, XML, XSL, XSD, XPATH, Web Services, Jini, JXTA for all type of Java Geeks.
Whoever posts spam / ads / job related message will be BANNED IMMEDIATELYYahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/Java_Official/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/Java_Official/join
(Yahoo! ID required)

<*> To change settings via email:
Java_Official-digest@yahoogroups.com
Java_Official-fullfeatured@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
Java_Official-unsubscribe@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/

No comments:

Post a Comment