Link to home
Start Free TrialLog in
Avatar of adam_kan
adam_kan

asked on

Interfacing between C and JAVA

Hi,I am develeoping Network Sniffer ( or a Packet Sniffer)as my final year project and I want to write a gui using Java and then interfacing the gui with a C program that will dictate what is shown in the gui. I  am working on UNIX/LINUX platform.

I wanted to know if this is possible ? if yes ! what are the techniques that could be used to achieve this.

thanks.

 

Avatar of Exceter
Exceter
Flag of United States of America image

Yes it is possible. I would say that the simplest method is to have the C program write the sniffed data to a file and have the Java GUI read it in and display it.
well there is one more better way..
learn about JNI.. in that u can call C/C++ functions from java classes..
so whatever sniffing data u r getting from C functions u can pass on that to the JAVA method . using JNI interfaces..
start with sample JNI programs .. which will tell u how to process simple String with C functions passed from java and return back to the java program..
try on ur own and tell us if u r stuck .. btw i am interested in ur project .. as i like JNI,and C on LINUX and also i have ideas abt network sniffers.. :-)
also when u proceed like this .. write to file and read from it .. then u'll have problems .. of locking the read and write processes on the data file..
u'll have a lot of issues to take care of.. like..
when ur sniffer is writing the data to the file ..u have to make sure ..java program isnt reading it ..
this is more critical when u are using the file data as a buffer... i mean u have fixed maximum size of the data file and u keep deleting the old data ..when u have file on maximum size and there is new data to be written.
.
a lot also depends on how wud u like to present ur data in the GUI.. like constant-monitoring/ batch-monitoring(daily/hourly/..)
ASKER CERTIFIED SOLUTION
Avatar of Paul Maker
Paul Maker
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of adam_kan
adam_kan

ASKER

Thank you for your efforts in answering my question.
It was of great help. Are there any other methods of achieving this task? i mean any simpler-ones.

Once again, your help much appreciated.

thank you
adam
Hi akshayxx

I really want to thank you for taking you time in answering my question. It has been of enormous help.

I am using Expert Exchange for the first time, and  I was unaware of the fact that you are only allowed to choose one comment as an answer. Obviously your answer deserves the max-point as it has provided me the much needed help.

Please let me know if there is a way of changing the "accepted answer" as you receive all the points.

Also, is it possible if i can get in touch with you on email, my email is: adam_kan2000@yahoo.co.uk

With thanks
regards
asad

never mind .. its enough for me that . u acknowledge that my comments helped u out .. and more important is that it helped you..
so forget about points ..and in future if u feel u wanna give credits to more than one person . then do this .. in community support topic .. post a request to split the points ..
OR
give the current points to some one .. and for other make another question with heading .. points for ABCD..
thats enough..
also .. i can be contacted on akshay40@hotmail.com