import java.lang.reflect.*;
import java.awt.*;
import java.lang.*;
class SampleField
{ public static void getField(Class c)
{ //Class c= Class.forName(s);
Field f[]=c.getFields();
for(int i=0;i<f.length;i++)
{ System.out.println(" ");
Class type=f[i].getType();
System.out.print(type.getName());
System.out.print(""+f[i].getName());
}
}
public static void main(String... s1)
{ try{
Class c= Class.forName(s1[0]);
getField(c);
}catch(Exception e){System.out.println(e);}
}
}
I have written the above code for finding out the data fields of any class.I am passing the name of the class as a string through command line argument but getting an exception:ClassNotFoundException.. please help me to overcome my problem. THANKS