I'm attempting to run a program using the command:
java Honey -cp ../../jnetpcap-1.3.0/jnetpcap.jar
and am getting the title error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/jnetpcap/Pcap
at Honey.main(Honey.java:18)
Caused by: java.lang.ClassNotFoundException: org.jnetpcap.Pcap
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 1 more
I would greatly appreciate it if anyone could point out to me what I might be doing wrong.
-cp
like all JVM run-options only works if you put it before the name of the class you want to run, or the -jar
option if you use that to run the manifested main-class. Any tokens after the classsname or -jar
name are passed as arguments to your program . Once you fix that you will find that you need your classpath to contain both the jnetpcap jar and also your class(es), so you need something like
jar -cp .:path/to/jnetpcap.jar Honey
# on Windows use ; instead of :
You must explicitly tell the JVM where is the native library.
Try something like this
sudo ../jdk1.8.0_45/bin/java -Djava.library.path=/home/leoks/Downloads/jnetpcap-1.3.0 -cp .:jnetpcap.jar Honey
I don't know how "Honey" looks like, so I've used this instead
http://jnetpcap.com/?q=examples/classic
For this specific example, since it requires some special permissions, I've run it using sudo.
For this example I've downloaded jnetpcap for ubuntu 64-bit from here
I've used Oracle JDK 1.8.0_45 and Ubuntu 14.04.2 LTS
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.