Interface Finder  Interface Finder

go to home page Student Projects full screen, hide local find menu Google search web for more information on this topic jump to foot of page translate this page with Babelfish by Roedy Green ©1996-2008 Canadian Mind Products
This essay is about a suggested student project in Java programming. This essay gives a rough overview of how it might work. It does not describe an actual complete program. I have no source, object, specifications, file layouts or anything else useful to implementing this project. Everything I have to say to help you with this project is written below. I am not prepared to help you implement it; I have too many other projects of my own.

I do contract work for a living, which could include writing a program such as this. However, I don’t do people’s homework for them. That just robs them of an education.

You have my full permission to implement this project any way you please.

This project is related to the Path and Classpath tool project and Which and What Project: path and classpath analysis projects in that they involve analysing the classpath.

This project is easy in that it requires no design or user interface. It is an exercise in fiddling bits and using JDK methods.

Let us say you have written code that will allow the user to add it own plugins, simply by implementing some interface. It would be nice to list all possible classes on the classpath that implement the interface (or extends a given class), so that you can add them to a JComboBox to let the user select which of all possible plug-in he wants to use.

How do you prepare the list?

  1. Get the classpath as a from the system properties.
  2. In Windows, split it at the semicolons with Regex.split. In Linux, split it at the colons. In general, split it at the File. pathSeparatorChar.
  3. Collect a list of all independent class files on the classpath by using File.list using a filter.
  4. Similarly, collect a list of all class files in jars and zips.
  5. Using your knowledge of the class file format, check each class file to see if it implements the desired interface of class. It if does add it to your Set. You might use BCEL (Jakarta Byte Code Engineering Library. However, it will probably be faster to roll your own chase through the bytes to get just what you want, rather than turning on a full blown analyser.
  6. Return an array of fully qualified class names with dots to the caller.
Then write a variant that will search for a given particular class (not just that extends a given class) and tell you which directory on the classpath or in which jar it lives. You might even start with that easier problem, since it does not require scanning the class file binaries.

Most of what you need for a classpath search is implemented in ZipLock. See the storeClass(String className) method and the openResource(,) method it calls.

jar
jar verifier Project
JarCheck
JarLook
Java Jar Catalog Project
Path and Classpath tool project
Which and What Project: path and classpath analysis

CMP homejump to top
CMP logo
feedback Please email your feedback for publication, errors, omissions, broken/redirected link reports
and suggestions to improve this page to Roedy Green : feedback email
made with CSS
HTML Checked!
ICRA ratings logo
mindprod.com IP:[65.110.21.43]
Your face IP:[38.103.63.59] The information on this page is for non-military use only.
You are visitor number 865. Military use includes use by defence contractors.
You can get a fresh copy of this page from: or possibly from your local J: drive (Java virtual drive/mindprod.com website mirror)
http://mindprod.com/project/interfacefinder.html J:\mindprod\project\interfacefinder.html