JNI errors when compiling the C file?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Talal_jaafar
Posted On:   Wednesday, March 13, 2002 12:16 PM

I am trying to use JNI to make a call to a c method from a Java class. I followed the instruction of the tutorial on java.sun.com, but I am stuck when I am trying to create the shared library. I am getting the following errors: HelloWorld.h: Syntax error before void I don't know what is the problem since it was a simple "copy and paste" from the java tutorial. Here is the part of the HelloWorld.h: JNIEXPORT void JNICALL Java_HelloWorld_displayHelloWorld(JNIEnv *env, jobject obj); Can anybody help me?? Also, if you know a better way to call a c method from a Java class, let me know please. Thanks    More>>
			
I am trying to use JNI to make a call to
a c method from a Java class. I followed the instruction of the tutorial on java.sun.com, but I am stuck when I am trying to create the shared library. I am getting the following errors:


HelloWorld.h: Syntax error before void




I don't know what is the problem since it was a simple "copy and paste" from the java tutorial.




Here is the part of the HelloWorld.h:


JNIEXPORT void JNICALL
Java_HelloWorld_displayHelloWorld(JNIEnv *env, jobject obj);




Can anybody help me?? Also, if you know a better way to call a c method from a Java class, let me know please.


Thanks
   <<Less

Re: JNI errors when compiling the C file?

Posted By:   Paro_Bibi  
Posted On:   Thursday, March 14, 2002 09:22 PM

To call a C function follow these steps:
1. First write java code and compile it.
2. Now use the javah utility and create the header file as
javah -jni HelloNative
3. Then write your C code.
4. Finally create Dll.

I hope it will help u.
About | Sitemap | Contact