Re: Extracting class data from a jar
- From: dagon@xxxxxxxxx (Mark Rafn)
- Date: Mon, 23 Oct 2006 14:00:58 -0700
Tony Burrows <tony@xxxxxxxxxxxxxxx> wrote:
I'm building an app which lets users drag and drop classes into a tree,
followed by code generation. For this, I need to have (a) a list of all
the classes which can be dragged and (b) for each class, which of the
others can be a parent in the tree.
How do you decide which classes can be dragged, and what can be a parent?
All the relevant classes are in a jar file (j3dcore.jar) as well as
other abstract classes and there is standard generated documentation.
Typically, a combination of requiring the jar to have a specific config file
or manifest in the jar, and use of reflection on classes listed in that config
does the trick.
Any idea how I could extract the relevant data? Hand coding it would be
just too much.
How would we know what data is relevant? You can use the
java.util.jar.JarFile class to read contents of a jar (including files and
Manifest entries), and java.lang.Class (either from your classloader via
Class.forName(className) or from a URLClassLoader under your control via
loadClass(classBinaryName).
If this tree is known at build-time for the jar, it's really going to be
easiest to put the relevant data into manifest entries or into a specific XML
file in META-INF that you can read and use, rather than guessing based on
looking at every class in the jar.
--
Mark Rafn dagon@xxxxxxxxx <http://www.dagon.net/>
.
- References:
- Extracting class data from a jar
- From: Tony Burrows
- Extracting class data from a jar
- Prev by Date: Re: Extracting class data from a jar
- Next by Date: 3D & web application ?
- Previous by thread: Re: Extracting class data from a jar
- Next by thread: JSEE certification/exam
- Index(es):
Relevant Pages
|
|