How to unload library (DLL) from the JVM
Asked Answered
B

1

39

I need to unload a DLL that was loaded with System.loadLibrary(..), anyone know if this is possible?

Bottoms answered 17/1, 2009 at 14:18 Comment(0)
A
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:

Architrave answered 17/1, 2009 at 14:32 Comment(1)
I 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!Peltz

© 2022 - 2024 — McMap. All rights reserved.