java 反射的问题
package fff;import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
public class Text {
/**
* @param args
* @throws Exception
* @throws SecurityException
*/
public static void main(String[] args) throws SecurityException, Exception {
String fileName="fff.Student";
//Student s=new Student();
Class clazz=Class.forName(fileName.trim());
Constructor constructor=clazz.getConstructor();
Object s=constructor.newInstance();
Method method=clazz.getMethod("setAge", Integer.class);
method.invoke(s, 12);
}
}
Student这个类的class文件是我从其他地方考过来,放到bin/fff目录下的(Student.class,这个文件已经确认正确)为什么运行的时候会报错
Exception in thread "main" java.lang.NoClassDefFoundError: fff/Student (wrong name: com/guo/big/Student)