hi ppl..... i hav got a query.... of how to retrive which all classes are present in . java file... i.e i want the name of the the classes in a . java file...........
actually my original problem is that at runtime i want to find out the class that contain the main() in a . java file... hope it wil b solved thanks in advance.....
Sounds like you need to parse the file with some sort of regular expression to match the pattern you are after. java.io.* and java.util.regex.* should help.
This is tricky, as there is no one particular string you can look for. Even using regexps there are quite few possibilities of how a main method might look like. It would be easier to do this with class files instead of source files, since you can use reflection to look for the one signature that indicates a main method.