Skip to Main Content

Java HotSpot Virtual Machine

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Errors while compiling C++ file for JNI

843829Oct 31 2008 — edited Nov 5 2008
Hi all

I'm trying to create a simple "hello world" in C++ and call it form java class.I followed the tutorial from SUN to implement this.I generated '.h' file for java class and using that method
signature in the c++ function.However i'm getting these errors

`JNICALL' does not name a type
'JNIESPORT' does not name a type

here is my c++ code: ('HelloWorld.h" is the file generated from java class using the command javah -h classname)

#include <iostream>
#include <jni.h>
#include <iostream.h>
#include "HelloWorld.h"

using namespace std;

JNIEXPORT void JNICALL Java_HelloWorld_print_1hello
(JNIEnv *, jobject){

cout<<"welcome sree!!"<<endl;

};


I'm doing anything wrong?? or did the jni.h file is not included properly.Any help is appreciated.

thanks,
Sree
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 3 2008
Added on Oct 31 2008
14 comments
2,857 views