My Own ClassLoader with Class.forName(String className);
Hello All,
I have tryed to implement my own ClassLoader to do some extra work when each class is loaded.
My ClassLoader try to find the class in a classpath first, and if the class is not found, it should find the class in some directory specified by me and instantiate it.
I have created a custom classloader but the problem is that when any class is loaded with Class.forName(String className) it uses the current ClassLoader not the one specified by me with -Djava.system.class.loader option. :(
Can anyone please advice me on the same.?
Thanks in advance. :)
Rajendra
> I have created a custom classloader but the problem
> is that when any class is loaded with
> Class.forName(String className) it uses the current
> ClassLoader not the one specified by me with
> -Djava.system.class.loader option. :(
Hello,
Did you try specifying the classloader :
Class.forName(className, ClassLoader.getSystemClassLoader())
> I have created a custom classloader but the problem
> is that when any class is loaded with
> Class.forName(String className) it uses the current
> ClassLoader not the one specified by me with
> -Djava.system.class.loader option. :(
How did you determine that is it not using yours?
Technically that shouldn't really be possible.That option replaces the loader, so there is no other loader available.
Are you sure that the problem isn't that your loader just isn't finding the class via the alternative method?