简体   繁体   中英

JpcapHandler wont work

So here's the thing. Im trying to let a network sniffer work, but this annoying problem just showed up that says the JpcapHandler cannot be resolved to a type. I've imported the jpcap library already. Dont know how to solve tis issue. Please help me with this. I'm kinda new in network programming. 在此处输入图片说明

Are you sure you added the library to your project's build path? (Looks like you're using Eclipse) copying the jar to some /lib folder somewhere won't do the trick. Also are you sure this class is in the package?

I suggest opening the 'JpcapHandler' jar with a decompiler and analyze this class (if you can find it there): http://jd.benow.ca/

Once you confirm where the class is, you should consider organizing your import statements. Usually your IDE would create the import line for you if the jar is in the build path, you should see the import option among the IDE suggestions for the line that is presenting the problem.

If you are definitely sure that you've added the jar to the build path, I recommend that you create a new class and run the following code to see if the JVM instance (the one that is initiated by Eclipse when you run your program) can find this jar.

<%@ page import="java.security.*" %>
<%@ page import="java.net.URL" %>
<%
Class cls = com.some.package.that.I.dont.know.JpcapHandler .class;
ProtectionDomain pDomain = cls.getProtectionDomain();
CodeSource cSource = pDomain.getCodeSource();
URL loc = cSource.getLocation();
out.println(loc);
// it should print something like "c:/workspace/SomeNetworkingProject/lib/JpcapHandler.jar"
%>

This will tell you the exact jar that is being loaded by your JVM, it might help you understand what's going on.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM