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 ©1996-2009 Roedy Green, Canadian Mind Products
This essay does not describe an existing computer program, just one that should exist. This essay is about a suggested student project in Java programming. This essay gives a rough overview of how it might work. I have no source, object, specifications, file layouts or anything else useful to implementing this project.

This project outline is not like the artificial tidy problems you are spoon-fed in school, when all the facts you need are included, nothing extraneous is mentioned, the answer is fully specified, along with hints to nudge you toward a single expected canonical solution. This project is much more like the real world of messy problems where it is up to you to fully the define the end point, or a series of ever more difficult versions of this project, and research the information yourself to solve them.

Everything I have to say to help you with this project is written below. I am not prepared to help you implement it; or give you any additional materials. I have too many other projects of my own.

Though I am a programmer, 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 in any way you please and to keep all the profits from your endeavor.

Please do not email me about this project without reading the disclaimer above.

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 You can get the freshest 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
CMP logofeedback Please email your feedback for publication, errors, omissions, typos, formatting errors, ambiguities, unclear wording, broken/redirected link reports, suggestions to improve this page or comments to Roedy Green : feedback email
mindprod.com IP:[65.110.21.43]
view BlogYour face IP:[38.107.191.107]
You are visitor number 2,397.