Hi All,
I would like to summarize the steps followed to run the JNI code:
1. Wrote a
Java program named "HelloWorld.java" in eclipse:
2. Using External Tools Configurations, tried creating a Header file for the above class. The system generated header file:
3. Wrote the C implementation of the HelloWorld class as:
I am using Netbeans 6.8
IDE to create the C Source file.
Compiler: Cygwin (gcc 3.4.4)
When I compile the above code, I am getting a no. of errors in <jni.h>
The output window of Netbeans looks something like this:
MS-DOS style path detected: C:\Program Files\Java\jdk1.5.0_11\include\jni.h.gch
Preferred POSIX equivalent is: /cygdrive/c/Program Files/Java/jdk1.5.0_11/include/jni.h.gch
CYGWIN environment variable option "nodosfilewarning" turns off this warning.
Consult the user's guide for more details about POSIX paths:
http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
from HelloWorld.c:2:
In file included from HelloWorld.h:8,
C:\Program Files\Java\jdk1.5.0_11\include\jni.h:169: error: conflicting types for 'JNINativeMethod'
C:\Program Files\Java\jdk1.5.0_11\include\jni.h:169: error: previous declaration of 'JNINativeMethod' was here
C:\Program Files\Java\jdk1.5.0_11\include\jni.h:182: error: redefinition of typedef 'JNIEnv'
C:\Program Files\Java\jdk1.5.0_11\include\jni.h:182: error: previous declaration of 'JNIEnv' was here
C:\Program Files\Java\jdk1.5.0_11\include\jni.h:196: error: redefinition of typedef 'JavaVM'
C:\Program Files\Java\jdk1.5.0_11\include\jni.h:196: error: previous declaration of 'JavaVM' was here
C:\Program Files\Java\jdk1.5.0_11\include\jni.h:199: error: redefinition of `struct JNINativeInterface_'
C:\Program Files\Java\jdk1.5.0_11\include\jni.h:762: error: redefinition of `struct JNIEnv_'
C:\Program Files\Java\jdk1.5.0_11\include\jni.h:1840: error: redefinition of `struct JavaVMOption'
C:\Program Files\Java\jdk1.5.0_11\include\jni.h:1843: error: redefinition of typedef 'JavaVMOption'
C:\Program Files\Java\jdk1.5.0_11\include\jni.h:1843: error: previous declaration of 'JavaVMOption' was here
C:\Program Files\Java\jdk1.5.0_11\include\jni.h:1845: error: redefinition of `struct JavaVMInitArgs'
C:\Program Files\Java\jdk1.5.0_11\include\jni.h:1851: error: redefinition of typedef 'JavaVMInitArgs'
C:\Program Files\Java\jdk1.5.0_11\include\jni.h:1851: error: previous declaration of 'JavaVMInitArgs' was here
C:\Program Files\Java\jdk1.5.0_11\include\jni.h:1853: error: redefinition of `struct JavaVMAttachArgs'
C:\Program Files\Java\jdk1.5.0_11\include\jni.h:1858: error: redefinition of typedef 'JavaVMAttachArgs'
C:\Program Files\Java\jdk1.5.0_11\include\jni.h:1858: error: previous declaration of 'JavaVMAttachArgs' was here
C:\Program Files\Java\jdk1.5.0_11\include\jni.h:1862: error: redefinition of `struct JDK1_1InitArgs'
C:\Program Files\Java\jdk1.5.0_11\include\jni.h:1884: error: redefinition of typedef 'JDK1_1InitArgs'
C:\Program Files\Java\jdk1.5.0_11\include\jni.h:1884: error: previous declaration of 'JDK1_1InitArgs' was here
C:\Program Files\Java\jdk1.5.0_11\include\jni.h:1886: error: redefinition of `struct JDK1_1AttachArgs'
C:\Program Files\Java\jdk1.5.0_11\include\jni.h:1888: error: redefinition of typedef 'JDK1_1AttachArgs'
C:\Program Files\Java\jdk1.5.0_11\include\jni.h:1888: error: previous declaration of 'JDK1_1AttachArgs' was here
C:\Program Files\Java\jdk1.5.0_11\include\jni.h:1895: error: redefinition of `struct JNIInvokeInterface_'
C:\Program Files\Java\jdk1.5.0_11\include\jni.h:1911: error: redefinition of `struct JavaVM_'
make: * [build/Debug/Cygwin-Windows/HelloWorld.o] Error 1
BUILD FAILED (exit value 2, total time: 1s)
I dont think so that any change in jni.h is needed. Its something which compiler is not understanding. Don't know what.
Please help.