Hyperic Sigar Mac Osx Error -No Library
Asked Answered
O

3

5

Hi im using a third party lib name Hyperic Sigar. When i run my code it shows error,

This is my code:

package pack;

import org.hyperic.sigar.*;

public class NetworkData {
    public static void main(String[] args) {
   Sigar sigar = new Sigar();
    }

}

This is the error message:

1 [main] DEBUG Sigar  - no libsigar-universal64-macosx.dylib in java.library.path
org.hyperic.sigar.SigarException: no libsigar-universal64-macosx.dylib in java.library.path
    at org.hyperic.sigar.Sigar.loadLibrary(Sigar.java:172)
    at org.hyperic.sigar.Sigar.<clinit>(Sigar.java:100)
    at pack.NetworkData.main(NetworkData.java:10)

Im developing on Mac Osx Snow Leopard Using Eclipse IDE for Java Developers is found some old post("no sigar-x86-winnt.dll in java.library.path" error when using Hyperic SIGAR on multi language OS) The post says that i need to add some path, if so... How do i add that path in Mac Osx? Do hope someone can help^^

Organizer answered 29/6, 2012 at 18:14 Comment(0)
V
5
 # to find it later because you will need it ...
 cd ~/Downloads/

 # or whatever the latest one at the time of reading is ... 
 curl https://netix.dl.sourceforge.net/project/sigar/sigar/1.6/hyperic-sigar-1.6.4.zip

 # unpack the package to the tmp dir
 sudo unzip -o /Users/phz/Downloads/hyperic-sigar-1.6.4.zip -d /tmp/

 # copy the libsigar-universal64-macosx.dylib to your class path dir
 sudo find /tmp/ -name libsigar-universal64-macosx.dylib \
   -exec cp -v {} /Library/Java/Extensions/ \;

 # this cmd might be obsolete ... 
 # copy the sigar.jar to your class path dir
 sudo find /tmp/ -name sigar*.jar \
   -exec cp -v {} /Library/Java/Extensions/ \;

 # set you classpath dir, or add in ~/.bash_profile
 # or even better https://github.com/YordanGeorgiev/ysg-confs
 export CLASSPATH=$CLASSPATH:/Library/Java/Extensions

 # you should not see the error anymore 
 cd $my_proj_dir ; sbt compile

 # neither here .. 
 cd $my_project_dir ; clear ; sbt "test:testOnly *testClass"
Vincennes answered 19/10, 2017 at 10:46 Comment(1)
For me, it was enough to download sigar.zip from sourceforge.net/projects/sigar and extract libsigar-universal64-macosx.dylib to /Library/Java/Extensions/. This removed the warning from IntelliJ scala test run.Victualler
E
3

First You need to add Sigar.jar to your library, then add .dylib file to your library (you need to pick file for your OS what you are using). In your case you should add libsigar-universal64-macosx.dylib you can find these files in "hyperic-sigar-1.6.4/sigar-bin/lib".

Entourage answered 27/9, 2012 at 10:27 Comment(0)
O
2

I got the solution, The solution is adding a jar file(in my case) to my project. Is the same concept whenever we use a third party library,like mysql driver for java. So in my case, i need to add log4j.jar and sigar.jar to my path.

Right click on your eclipse project then go to Build Path > Configure Build Path > Java Build Path > Add External JARs and add in sigar.jar to your project.

Organizer answered 12/10, 2012 at 7:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.