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

Lets say that the tshark command for piping the output from tshark is :

tshark -i your_interface -n | your_program

I would like to pipe the output from tshark to the java program.

I compiled the java file and i piped the tshark output to the java program like this :

tshark -i 1 -n | java "C:\Users\L33604\Desktop\Eclipse Indigo x64-Bit\eclipse\project workspace\Splunk Project\src\Program.class"

The error was thrown :

could not find or load main class : C:\\..... tshark an error occurred while printing packets : invalid arguement.

The question is what is the way to pipe the tshark output to the java program using tshark command?

asked 01 May '12, 18:13

misteryuku's gravatar image

accept rate: 0%

edited 01 May '12, 23:57

grahamb's gravatar image

grahamb ♦

"could not find or load main class" is a Java error; there's something wrong with your program or with the way you're running it with the "java" command. I can't help you with that.

"an error occurred while printing packets : invalid argument" may just be an error given when TShark tries to write to a pipe when the program on the other side of the pipe has terminated.

permanent link

answered 01 May '12, 19:17

Guy%20Harris's gravatar image

Guy Harris ♦♦
accept rate: 19%

---- "could not find or load main class"

As already mentioned, there is something wrong with your java class file, most certainly the main method is missing in your class file. I think you will get more detailed information in a Java forum.

Here is a working example:


public class Echo { public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(; String s; while ((s = in.readLine()) != null && s.length() != 0) System.out.println(s); // An empty line or Ctrl-Z terminates the program } } ///:~

Compile it: javac

Run it: tshark -i 1 -n | java Echo

Note: just 'java Echo' not 'java Echo.class', as it would expect a main method then!


Capturing on VMware Accelerated AMD PCNet Adapter (Microsoft's Packet Scheduler)
0.000000 -> ICMP 74 Echo (ping) request id=0x0200, seq=15106/571, ttl=128
0.000116 -> ICMP 74 Echo (ping) reply id=0x0200, seq=15106/571, ttl=128

Hint: This is buffered input stream reading, so it take some time until the code prints something on the CLI (the buffer needs to be filled first).

---- "tshark an error occurred while printing packets : invalid arguement"

I have no idea where that comes from. Does this work without errors on your system: tshark -i 1 -n


permanent link

answered 01 May '12, 21:56

Kurt%20Knochner's gravatar image

Kurt Knochner ♦
accept rate: 15%

Your answer
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: 01 May '12, 18:13

question was seen: 6,204 times

last updated: 01 May '12, 23:57

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