calling another program
I have gone thru the jni tutorial and I understand the HelloWorld example... my problem is, in the tutorial the java part calls a C program that they then write... I need to call an existing program that is not written in java? I have this program's header file and that is all.
How do I use this so that my java program can call the existing non java program? What do I do with it ? The methods sigs. in the non java program's header file do not look like the ones created by javah.exe.
am I way off?, this is possible right?
please help, and thanks in advance
[596 byte] By [
yeti17] at [2007-9-26 2:56:20]

I was doing the same thing a couple of weeks ago. You need to write C wrappers for the library you want to use.
Say you have a function in the library:
char *functionA(char *param1);
Your java class would have a method like:
public native String functionA(String param1);
You'd generate the header with javah giving you the header for the function you have to implement. This would probably look something like:
jstring java_package_class_functionA(jnienv*, jclass, jstring)
Then in your C code implement the function like:
jstring java_package_class_functionA(jnienv*, jclass, jstring)
{
convert jstring to char *temp1
char *temp2 = functionA(temp1); // this will call your library function
convert temp2 to jstring
cleanup
return jstring version of temp2
}
Sorry I don't remember the exact syntax for everything.
Andrew