Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have installed WinPcap for capturing packet.. and i also copied some files .dll extension and paste in JDK.. but still some problems are in my first line i.e in "" import jpcap.JpcapCaptor"" i donot know why this is happening... though i copied and paste it (jpcap.dll) in my JDK... plz help.... and give some advice how to capture packets... my platform is netbeans 7.0

Java
import jpcap.JpcapCaptor; 
import jpcap.NetworkInterface; 
import jpcap.NetworkInterfaceAddress; 
import java.io.IOException; 
import java.util.Scanner; 
import javax.swing.JFrame; 

public class PacketAnalyser { static String text="";  
public String capture(){	   
	try { 
		captor=JpcapCaptor.openDevice(devices[index], 65535, true, 20); 
		long[] packs = new long[20]; 
		int tcp = 0; 
		int udp = 1; 
		for(int j = 0;j<10;j++){ 
		long count1 = 0; 
		long count2 = 0; 
		captor.setFilter("tcp and ip", true); 
		for(int i=0;i<10;i++){ 
			  
		text1=text1+captor.getPacket()+"\n"; 
		if(captor.getPacket()!=null){count1++;}} 
		text1=text1+captor.dropped_packets + " packets dropped by kernel\n"; 
		text1=text1+count1+"\n"  ; 
		captor.setFilter("udp and ip", true); 
		for(int i=0;i<10;i++){ 
		text1=text1+captor.getPacket()+"\n"  ; 
		if(captor.getPacket()!=null){count2++;} 
		} 
		text1=text1+captor.dropped_packets + " packets dropped by kernel\n"; 
		text1=text1+count2+"\n"; 
		packs[tcp]=count1; 
		packs[udp]=count2; 
		tcp+=2; 
		udp+=2; 
		} 
		
	captor.close(); 
	return text1; }}
Posted
Updated 10-Feb-12 21:48pm
v2
Comments
Richard MacCutchan 11-Feb-12 6:11am    
What problems? We cannot guess what messages you get when you try to compile this code.
Sathish H 7-Jan-16 0:59am    
Hi Richard,

I am using Avast antivirus software installed in my PC. I can block websites manually,but i need to block website Programmatically in C#(sharp) language.Please be free to help to find the solution.

Advance Thanks,
SathisH

1 solution

If your compiler or IDE is telling you that it doesn't like your very first import statement then the reason is that you have not included the jpcap jar(s) correctly for the compiler.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900