Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 236824

Re: JNLP loads Sigar native libs via file: but not http:

$
0
0

JNLP and Sigar classloaders do not play well together. This was pieced together but works well in both Windows and Mac environments. The VMWare forums HINT at an answer like this but no one has put it all together. For JNLP you need to specifically do a loadLibrary based on your architecture. In a non-JNLP context Sigar handles this transparently but JNLP breaks that somehow, requiring this manual platform selection.

Just put this method into your class and call it BEFORE you call new Sigar() and it should work properly. This solutions requires the commons-lang library. You can easily extend this for linux and other alternate platform support.

private static void preloadSigar() {        String arch = System.getProperty("os.arch");        String libName;        if (SystemUtils.IS_OS_WINDOWS) {            if (arch.equalsIgnoreCase("x86"))                 libName = "sigar-x86-winnt";            else                libName = "sigar-amd64-winnt";        } else if (SystemUtils.IS_OS_MAC_OSX) {            if (arch.startsWith("i") && arch.endsWith("86"))                libName = "sigar-universal-macosx";            else                libName = "sigar-universal64-macosx";        } else {            throw new RuntimeException("Unrecognized platform!");        }        System.setProperty("org.hyperic.sigar.path", "-");            System.loadLibrary(libName);      }

Viewing all articles
Browse latest Browse all 236824

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>