资 源 简 介
What is this?
This code is intended to solve a small, but annoying problem that occurs when loading native libraries (specifically DLLs) within a web container (Tomcat in this case).
Loading a DLL into a Web Container
Intuitively, the following code would be written to load a DLL within a web container.
System.loadLibrary("name-of-dll");
It is important to only call this method once, as calling it multiple times will result in the following error:
java.lang.UnsatisfiedLinkError: Native Library "name-of-dll" already loaded ...
Loading a DLL once in a Web Container
To correct for this issue, you can load the DLL in a static initializer block, which guarantees that it is only loaded once for the lifetime of the classloader assigned to that web container.
static { System.loadLibrary("name-of-dll");}
However, if the webapp is redeployed within a runni