I will get the classes dynamically,because i didn't know which new
Class has been add in to the package.
Martin Lansler - 25 Jul 2006 10:05 GMT
Don't think this is possible since the normal java classloader is lazy, i.e.
it only loads classes that are needed... There is no record over all
'avalable' classes.
Perhaps you could try to write your own classloader that scans through JVM
classpath.
Regards,
Martin.
>I will get the classes dynamically,because i didn't know which new
> Class has been add in to the package.
Paul Cager - 27 Jul 2006 00:08 GMT
> I will get the classes dynamically,because i didn't know which new
> Class has been add in to the package.
There isn't a foolproof way to do this, since classes can be loaded from
so many different sources - class files in directories, JARs, URLs etc.
And you could always write your own ClassLoader which might load classes
in a completely new way.
However if you know that your classes will always be in directories
listed in the CLASSPATH then you could use java.io.File to do the
searching - although this will be messy, fragile code. I believe there
is some "standard" tool to do it - have a google of this newgroup and
c.l.j.help as this question comes up quite regularly.
But as Jean-Francois Briere said, "Why do you want to do it?" There are
often better ways, such as using a properties file.