Reputation: 73
I'm trying to make a class loader that will load .class files inside a .zip file. I followed this tutorial (https://weblogs.java.net/blog/2008/07/25/how-load-classes-jar-or-zip), but when i run the program, i get this error:
java.lang.LinkageError: loader (instance of org/freeforums/geforce/genforcer/main/ZipClassLoader): attempted duplicate class definition for name: "test/TestClass"
The error comes from line 30, which is:
return defineClass(filename, out.toByteArray, 0, out.size());
I call the method by using:
zipClassLoaderObj.findClass("test.TestClass");
Does anyone know what i'm doing wrong?
Upvotes: 0
Views: 131
Reputation: 73
Found the problem. I was calling the method two times because it was in a 'for' loop with a bunch of other code. Just took it out of the loop, and now it works perfectly. Don't know why i couldn't figure that out myself. Thanks for the help!
Upvotes: 1