Ok,hab's nun hinbekommen...
import java.lang.reflect.InvocationTargetException;
public class KlassenLoader extends ClassLoader {
public static void main(String[] args) {
try {
Class klasse = Class.forName("LevelTest");
Object o = klasse.newInstance();
int testzahl2 = o.getClass().getField("testzahl").getInt(o);
System.out.println(testzahl2);
// Methodenaufruf testen
System.out.println(o.getClass().getMethod("getTeststring").invoke(o));
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (SecurityException e) {
e.printStackTrace();
} catch (NoSuchFieldException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
Markus