Open remram44 opened 12 years ago
This code shows the issue:
import jpype
jpype.startJVM('C:\\Program Files (x86)\\Java\\jdk1.6.0_25\\jre\\bin\\client\\jvm.dll')
url = jpype.java.io.File("C:\\classloadertest.jar").toURI().toURL()
classloader = jpype.java.net.URLClassLoader(jpype.JArray(jpype.java.net.URL)([url]))
c = classloader.loadClass("classloadertests.Test") # raises java.lang.NoClassDefFoundError
This is not even the correct exception; Java throws java.lang.ClassNotFoundException if no class with this name is found.
IMHO this should be fixed in JPype: https://github.com/remram44/jpype/issues/2
I wasn't able to find a workaround.
It should be possible to build a URLClassLoader to be able to load classes from JARs that were not present in the initial CLASSPATH. However, JPype's classloader seems to have a bug: if it doesn't find a class, it throws java.lang.NoClassDefFoundError without allowing the other classloaders to try.