You cannot know all classes in a package simply because the total number of them is infinity. You can determine all classes that have been loaded by using your own bootstrap classloader, or using your own agent that keeps a registry of loaded classes (see java.lang.instrumentation). You can also determine all packages (java.lang.Package) that have been loaded by a specific loader using Package.getPackages()
I can't make sense of the remainder of your question.
In general to get all the classes in a package THAT is on your classpath, you would need to have a routine that uses something like the File.list() method that would return all the files in a directory and then go thru them to find any files with paths that match the package you are looking for. The routine would have to be recursive (ie be able to go into sub folders) and also it would have to be able to read jar files.
What is the application that needs this information?
Joined: Jan 12, 2005
I' having to do a struts form. In one field i must find a list of differnt class name and then when choosed one i can modify some parameters about it saving them on database. These classes belong to another project in the same build path. My it' s a web application that configure the other one.
I can make a String list of that classes name but is more nice to have a runtime check & create the list