hi experts,
i am trying to build an application which requires a java and c
interconnection.
the applet has a textarea and it stores the contents entered in the
textarea in a file.
My c function, reads the content of the file and constructs a datagram
sends it to a System with a specified IP.. i am using linux
environment..
can i do this?
please help me..
thanking u in advance..
Xoinki.
Gordon Beaton - 29 May 2006 09:38 GMT
> i am trying to build an application which requires a java and c
> interconnection. the applet has a textarea and it stores the
> contents entered in the textarea in a file.
Which: an application, or an applet?
> My c function, reads the content of the file and constructs a
> datagram sends it to a System with a specified IP.. i am using linux
> environment.. can i do this?
You can use JNI to call C methods that have been written specifically
to be called from Java (i.e. you cannot call arbitrary C functions
directly, but since you can call them from your C methods this is not
usually a problem).
There is however nothing in your description of the C function that
can't be done directly in Java.
/gordon

Signature
[ do not email me copies of your followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e
Thomas Weidenfeller - 29 May 2006 09:44 GMT
> hi experts,
> i am trying to build an application which requires a java and c
> interconnection.
> the applet
Applet? If it is an applet, it requires some extra effort (signing) to
get access to C functions.
> My c function, reads the content of the file and constructs a datagram
> sends it to a System with a specified IP.
Why not doing this in Java, too?
> can i do this?
Check out JNI.
/Thomas

Signature
The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
http://www.uni-giessen.de/faq/archiv/computer-lang.java.gui.faq/
Bjorn Abelli - 29 May 2006 09:48 GMT
<manoharyes@gmail.com> wrote...
> i am trying to build an application which requires
> a java and c interconnection.
Which is possible through JNI.
http://mindprod.com/jgloss/jni.html
http://java.sun.com/developer/onlineTraining/Programming/JDCBook/jni.html
http://java.sun.com/j2se/1.5.0/docs/guide/jni/index.html
But maybe you're not really talking about "interconnectivity"?
> the applet has a textarea and it stores the contents
> entered in the textarea in a file.
Just write it to a textfile, in a format of your choice...
> My c function, reads
> the content of the file and constructs a datagram
> sends it to a System with a specified IP..
...read the file and parse the content. You have defined the format
yourself, so that wouldn't be any problem.
But where does the "interconnectivity" come in?
If you want to use *real* interconnectivity, you should use JNI in order to
call the function written in C directly from the Java GUI. No need to save
it to a file in between... ;-)
/// Bjorn A