Unable to open include file 'jni.h'
I have tried to realize the example of jdc of June 12,2001: Using Perr classes whit the JNI. But when I compile PeerLib.cpp using Borland C++ on Win32, by:
bcc32 -c -I/c:/jdk1.2.2/include -I/c:/jdk1.2.2/include/win32 PeerLib.cpp
the compiler tell me:
Error PeerLib.h 2: Unable to open include file 'jni.h'
Error PeerLib.h 15: Declaration syntax error
Error PeerLib.h 23: Multiple declaration for 'JNIEXPORT'
Error PeerLib.h 15: Earlier declaration of 'JNIEXPORT'
Error PeerLib.h 23: Declaration syntax error
Error PeerLib.h 31: Multiple declaration for 'JNIEXPORT'
Error PeerLib.h 23: Earlier declaration of 'JNIEXPORT'
Error PeerLib.h 31: Declaration syntax error
Error PeerClass.h 8: Namespace name expected
Error PeerLib.cpp 7: Multiple declaration for 'JNIEXPORT
Error PeerLib.h 31: Earlier declaration of 'JNIEXPORT'
Error PeerLib.cpp 7: Declaration syntax error
*** 12 errors in Compile ***
Someone can say me because it's unable to open file jni.h?
thanks
> I have tried to realize the example of jdc of June
> 12,2001: Using Perr classes whit the JNI. But when I
> compile PeerLib.cpp using Borland C++ on Win32, by:
> bcc32 -c -I/c:/jdk1.2.2/include
> -I/c:/jdk1.2.2/include/win32 PeerLib.cpp
>
> the compiler tell me:
>
> Error PeerLib.h 2: Unable to open include file
> 'jni.h'
> Error PeerLib.h 15: Declaration syntax error
> Error PeerLib.h 23: Multiple declaration for
> 'JNIEXPORT'
> Error PeerLib.h 15: Earlier declaration of
> 'JNIEXPORT'
> Error PeerLib.h 23: Declaration syntax error
> Error PeerLib.h 31: Multiple declaration for
> 'JNIEXPORT'
> Error PeerLib.h 23: Earlier declaration of
> 'JNIEXPORT'
> Error PeerLib.h 31: Declaration syntax error
> Error PeerClass.h 8: Namespace name expected
> Error PeerLib.cpp 7: Multiple declaration for
> 'JNIEXPORT
> Error PeerLib.h 31: Earlier declaration of
> 'JNIEXPORT'
> Error PeerLib.cpp 7: Declaration syntax error
> *** 12 errors in Compile ***
>
> Someone can say me because it's unable to open file
> jni.h?
> thanks
>
>
In the PeerLib.h file that javah generated for you there should be the line "#include <jni.h>".
Note the angle brakets before and after jni.h assumes that your C++ compiler knows where jni.h is. This not case. You either need to specify to your C++ compiler environment where jni.h is so you can use the syntax <jni.h> or you can specifically specify in your code where jni.h is by writing
#include "C:\jdk1.3.1\include\jni.h". Assuming your jkd is install at C:\jdk1.3.1. I hope this helps.
Pete Winson