Jnetpcap not working from commandline but works in eclipse

No replies
AnthonyMcGovern
Offline
Joined: 02/22/2017

Hi There
I was hoping someone might be able to point me in the right direction as to why im getting this error when running my application using java from the command line after compiling the java file with javac (which works with no errors). I have copied the dll (jnetpcap.dll) is in C:\Windows\System32 directory and set the ClassPath in windows:

C:\>echo %CLASSPATH%
C:\jnetpcap\jnetpcap.jar

The code works just fine when i run it in eclipse it capures IP addresses no problem. But when i try compiling the .java file from the command line using "javac PackageCapture" i dont get an error but i get 2 class files for some reason (see below):

C:\Users\Anthony.mcgoverna-lt\workspace_neon\packet_ver01\src\packet_sniffer>dir

Directory of C:\Users\Anthony.mcgoverna-lt\workspace_neon\packet_ver01\src\packet_sniffer

22-Feb-17 11:25 AM

.
22-Feb-17 11:25 AM ..
22-Feb-17 11:24 AM 6,456 PackageCapture.java
16-Feb-17 06:34 PM 1,566 sniff_ver1.java
2 File(Drunk 8,022 bytes
2 Dir(Drunk 336,621,965,312 bytes free

Then i compile the .java file (no errors)

C:\Users\Anthony.mcgoverna-lt\workspace_neon\packet_ver01\src\packet_sniffer>javac PackageCapture.java

Then i get 2 class files for some weird reason

C:\Users\Anthony.mcgoverna-lt\workspace_neon\packet_ver01\src\packet_sniffer>dir

Directory of C:\Users\Anthony.mcgoverna-lt\workspace_neon\packet_ver01\src\packet_sniffer

22-Feb-17 11:26 AM

.
22-Feb-17 11:26 AM ..
22-Feb-17 11:26 AM 2,027 PackageCapture$1.class
22-Feb-17 11:26 AM 2,517 PackageCapture.class
22-Feb-17 11:24 AM 6,456 PackageCapture.java
16-Feb-17 06:34 PM 1,566 sniff_ver1.java
4 File(Drunk 12,566 bytes
2 Dir(Drunk 336,621,957,120 bytes free

Then when i try and run the PacketCapture file using java i get an error below:

C:\Users\Anthony.mcgoverna-lt\workspace_neon\packet_ver01\src\packet_sniffer>java PackageCapture
Error: Could not find or load main class PackageCapture

Again it works perfectly fine in eclipse i have no idea why its not working when i run using javac/java can anyone help?