Search code examples
javaclassfindclassloader

Java ClassLoader format for defineClass with directories/packages?


So I am writing a custom ClassLoader to find classes in jars, but I can't find the right format for the defineClass() parameter "name". I've tried "d", "d.class", "a/b/c/d", "a.b.c.d" and probably a few others. Here is my Exception:

java.lang.NoClassDefFoundError: d (wrong name: a/b/c/d)

Does anyone know the proper way to format this?


Solution

  • The spearator is dot (.) and not slash (/) for path. So format of a.b.c.d should work if you are giving the right path.