posted 18 years ago
hi,
All the libraries are on the same path I mean current path where I am executing the existing c as well as my expermentations.
Existing Functionality:
I make a call to "int PE(char *pReport, char *pOutput)" in "parseexp.c" from "testexp.c".
*************************** parseexp.c ******************************
"int PE(char *pReport, char *pOutput)
{
.................
................
} "
***************************************************************************
******************************* testexp.c *********************************
char outrec[20000];
int ret;
if (ret=PE("",outrec)) {
printf("Error: %d\n",ret);
} else {
printf("%s\n",outrec);
}
***************************************************************************
the outrec variable is populated with some xml data.
My implementation:
I have written a wrapper to call the same c function and here is the code
************************** HelloWorld.c *****************************
JNIEXPORT void JNICALL
Java_HelloWorld_displayHelloWorld(JNIEnv *env, jobject obj)
{
printf("Hello world! namskara \n");
jchar outrec[20000];
jint ret;
if (ret=PE(" some text here ",outrec))
{
printf("Error: %d\n",ret);
} else {
printf("%s\n",outrec);
}
***********************************************************************
when I run the i get the earlier error message.
and all my files java's, c's , object libs, shared libs are all reside in the same directory.
I use following commands to
1) javac HelloWorld.java
2) javah -jni HelloWorld
3) cc -Ae +u4 +z -c -D_HPUX \ -I/opt/java1.4/include
-I/opt/java1.4/include/hp-ux \ HelloWorld.c
4) ld -b -o libHelloWorldLib.sl HelloWorld.o
5) export SHLIB_PATH=.;
6) java HelloWorld
I have few concern here
1) Are the data types I am passing to PE() are correct.if not what to pass???
2) Do I need to set any evnt variables?
cheersz
redsan74