How do I write C code in microsoft visual c++ 2010 Express
? I am unable to do it. I was writing some C code but it is compiled with errors.
Please suggest some way to do it?
I wrote this code:
#include "jni.h"
#include "stdio.h"
#include "HelloWorld.h"
JNIEXPORT void JNICALL
Java_HelloWorld_print(JNIEnv *env, jobject obj) {
printf("This is a JNI tester");
return;
}
I got the following error:
helloworld.cpp(1): fatal error C1083: Cannot open include file: 'jni.h' No such file or directory
I've never done JNI specific code but your error says it cannot find the file "jni.h". You probably need to drop that file inside your solution file or go in project options and in C/C++ options specify the folder where JNI header files are located. I'd recommend the later approach i.e. add the folder in include options of project.
Specific steps are:
go to your project properties
navigate in the tree to "Configuration Properties->C/C++" then look at the first entry "Additional Include Directories"
in there enter the path: "*JDKVersionPath*\include
";"*JDKVersionPath*\include\win32
"
Where JDKVersionPath is where your JDK install resides like C:\Program Files\Java\jdk1.6.0\
(the path version can especially vary depending on the version you have installed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With