Skip to main content

How to get the input file's class without knowing it (java)

No replies
Joined: 2012-11-05


I can't figure out, how to use getDeclaredMethods() (reflection) if the user chooses the file from GUI.
Something like this:

Class inclass= Class.forName("ClassName");
Method[] methods = inclass.getDeclaredMethods();

But I don't know "ClassName", I get it later.

I'd like to get the declared methods from the input file, and then list them in my GUI. The user can choose a txt or java file, when he/she did, the program will get the methods from this (if there are any) and list them on a jList.
Works if I know the Object's name, but not if it comes later.