Using SIGAR API inside a WAR file

不打扰是莪最后的温柔 提交于 2019-12-13 17:18:54

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!