Home > Back-end >  Who knows how Java release DLL written
Who knows how Java release DLL written

Time:09-23

tomcat service starts, by jna call DLL, how to release has call DLL . How to write code?

CodePudding user response:

Now a great god all don't go to CSDN

CodePudding user response:

I also encountered the same problems, seems to be no see have a direct release of JNA API

CodePudding user response:

NativeLibrary instance=NativeLibrary. GetInstance (StaticConstant. EDI_MIDDLEWARE_DLL);
The instance. GetFunction (" initial_DM "). The invoke (new Object [] {});
The instance. GetFunction (" gen_edi2carrier "). InvokeDouble (new Object [] {Java, jobD});
The instance. The dispose ();

CodePudding user response:

This kind of question yourself check the official document
https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/invocation.html#JNI_OnUnload
From the official documentation
The VM calls JNI_OnUnload The when The class loader containing The native library is garbage collected.
That is to say, don't you hand release, when load the DLL class class loader be garbage collected automatically when released,

So, want to hand release, then their release class loader
Refer to the following link example
https://web.archive.org/web/20140704120535/http://www.codethesis.com/blog/unload-java-jni-dll
  • Related