问题
I came across Sigar API from Hyperic (http://www.hyperic.com/products/sigar) which is a system information and reporting API for Java. It heavily uses JNI to gather data, and standalone version contains .SO and .DLL files in a /lib folder.
It works fine in Standalone mode, but I want to use this library inside a WAR. Is there anyway to do that without specifying the lib path in "-Djava.library.path" when starting the server? I want to be able to bundle it inside the WAR file and deploy it into a running server.
Thanks.
回答1:
I got it working with the following setup.
I copied all the content (SO / DLL) files to WAR file's lib folder. Then I deployed it to JBoss, and it worked without any custom system property setup.
Is this specific to JBoss? or can I expect this behavior in any J2EE compliant server?
回答2:
I was working on Sigar for a standalone java program where I had requirement to access host information. I had to use 'java.library.path' variable for loading JNI files. This path is used by Sigar APIs internally for loading libs. I configured this path using maven. You can refer here, if it helps.
Thanks.
来源:https://stackoverflow.com/questions/8286976/using-sigar-api-inside-a-war-file