I've got a pretty straightforward question, How can I get a class using it's name as a string? I saw this being used by a method in JavaPluginLoader (getClassByName(String)). However I can't find a way to actually get the JavaPluginLoader. Hope somone can help me out. Greets, Jeroen V.
JeroenV Code:java Class<?> clazz = Class.forName("class-name"); Please try and use google before posting for help here.
I did, for an hour actually. I guess I just got stuck too much with trying to use the JavaPluginLoader and focusses everything on that. I didn't know I could simply get it like that. Please excuse me for my ignorance. So something like this would work, right? Code: Class var = "FireScheduler".getClass(); OR Class<?> var = Class.forName("class-name"); Method meth = foo.getMethod("doSchedulerCode"); meth.invoke(meth, null);
JeroenV Don't use the first method, my guess would be that it would return the String class, which you don't want. Try the one I suggested, remember to specify the package. Eg. Code:java Class clazz = Class.forName("com.adamki11s.myclass");