I need to unload a DLL that was loaded with System.loadLibrary(..)
, anyone know if this is possible?
Asked
Active
Viewed 3.7k times
39

Lii
- 11,553
- 8
- 64
- 88

Alon Aizenberg
- 1,526
- 2
- 18
- 20
1 Answers
32
I don't have any experience of this, but a bit of digging shows that the library should be unloaded when the classloader which loaded the library is garbage collected.
Links:
-
1I just wasted 3 hours on this: The Java JNI DLL Unloading tutorial works, but **you cannot have a finalize() method in either your CustomClassLoader or your class that contains the native method!** I did not investigate why, but my guess is that it's related to the deprecation of finalize(). When removing the finalize from the example code everything works great! – mrexodia Mar 31 '20 at 14:18