diff --git a/bindings/java/src/net/hyperic/sigar/SigarLoader.java b/bindings/java/src/net/hyperic/sigar/SigarLoader.java index 2cce020e..9f9c8d0e 100644 --- a/bindings/java/src/net/hyperic/sigar/SigarLoader.java +++ b/bindings/java/src/net/hyperic/sigar/SigarLoader.java @@ -1,11 +1,14 @@ package net.hyperic.sigar; import net.hyperic.jni.ArchLoader; +import net.hyperic.jni.ArchLoaderException; import net.hyperic.jni.ArchName; import net.hyperic.jni.ArchNotSupportedException; public class SigarLoader extends ArchLoader { + private static String location = null; + public SigarLoader(Class loaderClass) { super(loaderClass); } @@ -34,4 +37,19 @@ public class SigarLoader extends ArchLoader { protected void systemLoad(String name) { System.load(name); } + + /** + * Returns the path where sigar.jar is located. + */ + public synchronized static String getLocation() { + if (location == null) { + SigarLoader loader = new SigarLoader(Sigar.class); + try { + location = loader.findJarPath("sigar.jar"); + } catch (ArchLoaderException e) { + location = "."; + } + } + return location; + } }