This is our old Q&A Site. Please post any new questions and answers at

Hi all,

At this moment, I am trying to implement a "one-click" packet capturing functionality (button on a GUI) in one of my JAVA applications, with the help of tshark/wireshark.

So far, I tried this:

String nic = NetworkInterface.getName();

String execute = "C:\Progra~1\Wireshark\tshark -i "+nic+" -b filesize:512 -w testCap";

try { Runtime.getRuntime().exec(execute); }

catch (IOException e1) { msg("Error during initialization of live capture"); e1.printStackTrace(); }

It turns out that String nic contains the name of the (via the GUI) selected local NIC, like for example "eth0."

I am using tshark on a pc running Windows7, and this type of NIC name that is returned by the method NetworkInterface.getName() is not recognized by tshark, since I receive the following message;

"tshark: The capture session could not be initiated (Error opening adapter: the system cannot find the device. (20)) Please check that "eth0" is the proper interface"

Any suggestions? Thanks a lot in advance!

asked 26 Apr '11, 10:56

robbertottenhof's gravatar image

accept rate: 0%

Be the first one to answer this question!
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 26 Apr '11, 10:56

question was seen: 3,999 times

last updated: 26 Apr '11, 10:56

p​o​w​e​r​e​d by O​S​Q​A