| Author |
Class.forName() method problem
|
yogesh kalaskar
Greenhorn
Joined: Jan 24, 2007
Posts: 6
|
|
package test_package; import java.lang.reflect.*; public class RunAnnotation { public static void main(String[] args) throws Exception { for (Method m : Class.forName("Generics").getMethods()) { System.out.println(m.getName()); } } } /////////////////////////////////////////////////////// This is small program ,wherein i am passing argument to Class.forname("nameOfClass").Both classes are in same package .but getting error like.. Exception in thread "main" java.lang.ClassNotFoundException: Generics Thanks in Advance Yogesh g k
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32599
|
|
Welcome to the Ranch. I got it to work by the simple technique of using the fully qualified name of the class. Try "test_package.Generics" as the class name. And why are you calling it "RunAnnotation" when it doesn't seem to do anything with annotations? CR
|
 |
 |
|
|
subject: Class.forName() method problem
|
|
|