public Class[] getClasses(String packageName) {
..........
}
A guy from Turkey<br /><a href="http://blogspot.serkandemir.com" target="_blank" rel="nofollow">http://blogspot.serkandemir.com</a>
Originally posted by Serkan Demir:
Can we get the list of Class objects in a given package?
Tony Morris
Java Q&A (FAQ, Trivia)
No, the number of classes that exists in a given package is finite at a given point in time, but infinite over time
It's not possible to write a getClasses method on Package because this information simply isn't available. If I load my classes over a socket, how is the client supposed to divine all of the class names on the (not necessarily Java based) server ?
Originally posted by Tony Morris:
Simply, there is no way to know of all classes within a package unless you define a finite context, such as a class loader.
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Originally posted by Peter Chase:
Even if you do specify that you want to know all the classes available to a particular ClassLoader, you still can't get them, can you? At least, not by any method that works for all ClassLoaders.
Tony Morris
Java Q&A (FAQ, Trivia)
Originally posted by jaikiran pai:
Can anyone explain what this means and why exactly is it not possible?
Originally posted by Tony Morris:
Sure it is.
You can even use a "Java agent" (see java.lang.instrumentation).
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Originally posted by Peter Chase:
Is this new in Java 5? I'm mostly stuck on 1.4.
Tony Morris
Java Q&A (FAQ, Trivia)
A guy from Turkey<br /><a href="http://blogspot.serkandemir.com" target="_blank" rel="nofollow">http://blogspot.serkandemir.com</a>
Jaikiran Pai wrote:Incidentally, i was trying to do the same just yesterday and here's what i found from some site:
There are no direct APIs to achieve this result. Also, the above code will not work if your classes are present in a jar file(code might need some modification to achieve this)
[ July 28, 2006: Message edited by: jaikiran pai ]
no wonder he is so sad, he hasn't seen this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|