Web application using JNI project should pay attention to the question of: Dong-issued time: 2004.12.20
JNI (Java Native Interface Application is generally a Java class, defining several Native methods in this class, and loads a dynamic library during the initialization of the class, such as the following class
Public class systeminfo {
STATIC {
System.loadLibrary ("SystemInfo");
}
Public static native long getPhysicalMemory ();
}
When the web project is used in this class and resolves the project (CONTEXT) due to other class modifications, this time the initialization of SystemInfo will excel, directly causes the systemInfo to be unavailable, because a dynamic library is not allowed twice in the JNI And it is impossible to uninstall the dynamic library loaded in front. How to solve the problem that CONTEXT is reloaded to cause the JNI class that cannot be tried? In fact, this problem is not difficult, we only need to reload the JNI class. However, a general application server is reloaded by default for web projects, such as web-inf / class, and web-inf / lib directory. In this way, we cannot put the JNI class in these two directories, but we must guarantee that this JNI class can be referenced by other classes of the web project, so this requires the setting of the class path of the different application servers. Tomcat, we can pack this JNI class separately and put in the {Tomcat} / common / lib directory and delete this JNI class in the Web project to resolve the previously mentioned issues. (T111)