L
learningjava
Hi,
Part of my looks like this:
Class c = null;
c = Class.forName("Car");
//class Car is defined in this file itself
Object object = c.newInstance();
ArrayList arg = new ArrayList();
ArrayList types = new ArrayList();
arg.add (new String("description"));
types.add(String.class);
Object[] argValues=arg.toArray();
Class[] argtypes=(Class[])types.toArray(new Class[argValues.length]);
Method method;
method=c.getMethod("description", argtypes);
The whole code compiles fine.
But I get a runtime error which says there was a ClassNotFoundException.
I have changed the CLASSPATH to include the directory in which these
programs sit, but am still getting the errors.
Help, please! Why doesn't it find my class?
Part of my looks like this:
Class c = null;
c = Class.forName("Car");
//class Car is defined in this file itself
Object object = c.newInstance();
ArrayList arg = new ArrayList();
ArrayList types = new ArrayList();
arg.add (new String("description"));
types.add(String.class);
Object[] argValues=arg.toArray();
Class[] argtypes=(Class[])types.toArray(new Class[argValues.length]);
Method method;
method=c.getMethod("description", argtypes);
The whole code compiles fine.
But I get a runtime error which says there was a ClassNotFoundException.
I have changed the CLASSPATH to include the directory in which these
programs sit, but am still getting the errors.
Help, please! Why doesn't it find my class?