Listing all packages and classes

Hello everyone,Package.getPackages() do not list all packages available in the JDK and no method to list package classes.I need to get all packages available and all classes in each package.Thank you
[227 byte] By [Gen.Javaa] at [2007-11-27 4:52:05]
# 1
> I need to get all packages available and all classes> in each package.You can't. Why do you think that you need it?Kaj
kajbja at 2007-7-12 10:05:59 > top of Java-index,Java Essentials,Java Programming...
# 2

As part of a larger application, I am creating an executer which lists classes and methods and let the user provide their parameters for on-the-fly execution.

Now, It is possible to list all packages by using dummy statements from each major package and "Package.getPackages()" will list related packages for you. But it is a bit tedious.

Now, listing pakage classes !!! I have no idea

Gen.Javaa at 2007-7-12 10:05:59 > top of Java-index,Java Essentials,Java Programming...
# 3

> Now, It is possible to list all packages by using

> dummy statements from each major package and

> "Package.getPackages()" will list related packages

> for you. But it is a bit tedious.

What do you mean?

> Now, listing pakage classes !!! I have no idea

As I said, it can't be done since you can load classes dynamically from any location.

Kaj

kajbja at 2007-7-12 10:05:59 > top of Java-index,Java Essentials,Java Programming...
# 4

> What do you mean?

if you run a very simple class that does not extend any JDK class, Package.getPackages() returns some 20 packages.However, if you extend javax.swing.JFrame for example, Package.getPackages() will return some 40 packages, and so on.

> As I said, it can't be done since you can load

> classes dynamically from any location.

Then how NetBeans (for example) lists all packages and their classes ?

Gen.Javaa at 2007-7-12 10:05:59 > top of Java-index,Java Essentials,Java Programming...
# 5
I would assume they just look through the jar files, instead of relying on the classloader to provide the information. For example, rt.jar contains most, if not all, classes from the standard libraries.
Herko_ter_Horsta at 2007-7-12 10:05:59 > top of Java-index,Java Essentials,Java Programming...
# 6

> Then how NetBeans (for example) lists all packages

> and their classes ?

You have in that case speficied the classpath for the project so NetBeans knows here to look. It will scan the jars, and folders that you have specified and list he classes. It will not be able to list any classes that you are loading dynamically unless you have them on the classpath.

Kaj

kajbja at 2007-7-12 10:05:59 > top of Java-index,Java Essentials,Java Programming...