I have more than one class loader:
- SystemClassloader
- a logical classloader (using URLClassLoader)
Java on Windows, OpenCV version 4.5.2
the jar is in the classpath, the DLL in the path.
Loading the library succeeds
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
but when I’m trying to use the APIs the link is unsatisfied.
for instance
Mat findFace = Imgcodecs.imread("C:\\image.jpg");
after closer look I noticed that loadLibrary
uses classloader of the caller class
Runtime.getRuntime().loadLibrary0(Reflection.getCallerClass(), libname);
but, the APIs are relying on SystemClassloader.
In debug I managed to make it working by evaluating the following statement
[00:28] Ivan Kostyuk
I did this in debug to prove it is working
ClassLoader.getSystemClassLoader().nativeLibraries.add(MyClass.class.getClassLoader().nativeLibraries.get(0))
This is ugly and cannot be implemented as a workaround, due to the field nativeLibraries
has default visibility and it is really ugly.
I think it is an issue with OpenCV.
Could you recommend me the next step to get it resolved?