This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
How can i do if i need to put in an array (or list) all class name of a package.
Ex. Package Gomez<--class Ginoz <--class Pinoz
I needemethd as: xx.method(Gomez) <-- this gimme String Ginoz & Pinoz strings
tnks [ September 11, 2005: Message edited by: Marco Vanoli ]
bye, <br />Marco
Tony Morris
Ranch Hand
Joined: Sep 24, 2003
Posts: 1608
posted
0
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.
Originally posted by Marco Vanoli: I needemethd as: xx.method(Gomez) <-- this gimme String Ginoz & Pinoz strings
If you are asking how to add the name to the List, I suggest you used the add() method of the List class. [ September 11, 2005: Message edited by: Marilyn de Queiroz ]
JavaBeginnersFaq "Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Norm Radder
Ranch Hand
Joined: Aug 10, 2005
Posts: 681
posted
0
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?
Marco Vanoli
Ranch Hand
Joined: Jan 12, 2005
Posts: 99
posted
0
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