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^^
# 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"
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"
.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With