Interfacing between C and JAVA

adam_kan
adam_kan used Ask the Experts™
on
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.

 

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
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.

Commented:
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.. :-)

Commented:
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/..)
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Author

Commented:
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

Author

Commented:
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

Commented:
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

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial