Question

I have a custom class loader which extends from a URLClassLoader. I added a .class file to the urlpath using addURL(); but when i do a class.forname() using this loader i get a ClassNotFoundException. However, if i create a jar and add the jar to the urlpath, i do not get any exception.

Using addURL(), can we add a .class file or a directory?? Can someone confirm this because it does not work for me?

Was it helpful?

Solution

addURL's argument should point to the directory containing the root package of your .class, not the file itself.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top