File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes IDEs, Version Control and other tools and the fly likes Unused classes Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Practical Unit Testing with TestNG and Mockito this week in the Testing forum!
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Reply Bookmark "Unused classes" Watch "Unused classes" New topic
Author

Unused classes

Dean John
Greenhorn

Joined: Jun 27, 2003
Posts: 1
Is there a tool or code to find unused classes.
Some details of the development environement are as follows -
IDE - IBM's WSAD
jdk version 1.3
Creating web application using Servlet/Jsp.
Thanks.
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Originally posted by Dean John:
Is there a tool or code to find unused classes.
Some details of the development environement are as follows -
IDE - IBM's WSAD
jdk version 1.3
Creating web application using Servlet/Jsp.
Thanks.

Need a little clarification here. Do you mean what classes are not used from a particular jar or war file or package? In the current implementation of java.lang.ClassLoader there is a private Vector named classes that holds a reference to all Classes that have been loaded. With reflection you can possibly change the access level from private to public and get at that Vector. If you can't do it, it will be because of a SecurityException.


Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Welcome to JavaRanch, Dean!
I've not made a mental note of any products that purport to search for unused classes. Borland's Optimizeit Code Coverage for Java does claim to allow "developers to view in real time how frequently each class ... is executed." I suppose this might get the job done for you.
[ June 29, 2003: Message edited by: Dirk Schreckmann ]

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
I'm moving this to the IDEs and Other Tools forum...
Jon Strayer
Ranch Hand

Joined: Dec 04, 2002
Posts: 133
Try RefactorIT
Not Used Finds unused classes, interfaces and members with the whole project or within a package.


Jon
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6913
Or for a more practical approach, you could look at genjar. It enables you to build a jar file (or directory of class files) containing only the classes you need, regardless of where they came from. I use it all the time to "trim the fat" from my web applications.
[ June 29, 2003: Message edited by: Frank Carver ]

A Convergent Visionary ~ Frank's Punchbarrel Blog ~ LinkedIn profile
 
 
subject: Unused classes
 
Threads others viewed
Total loaded classes in Glassfish
finding dead/unused code in web application
Problem with properties file
Can I Reduce the size of JDK
tool to identify unused methods
MyEclipse, The Clear Choice