C
cppaddict
I have a very simple JNI function that returns a jstring type, but I
can't get it to compile. My implementation file looks like this:
#include <jni.h>
#include "HelloWorld.h"
#include <iostream>
#include <string>
JNIEXPORT jstring JNICALL Java_HelloWorld_getHelloWorld
(JNIEnv *env, jobject obj)
{
std::string str = "Hello World";
return (*env)->NewStringUTF(env,str.c_str()); //COMPILER ERROR
}
The compiler error is:
Error E2288 HelloWorld.cpp 10: Pointer to structure required on left
side of -> or ->* in function __stdcall
Java_HelloWorld_getHelloWorld(JNIEnv_ *,_jobject *)
I followed the example at the bottom of this page:
http://java.sun.com/docs/books/tutorial/native1.1/implementing/string.html
so I don't know what's going wrong. Can anyone help?
Thanks,
cpp
can't get it to compile. My implementation file looks like this:
#include <jni.h>
#include "HelloWorld.h"
#include <iostream>
#include <string>
JNIEXPORT jstring JNICALL Java_HelloWorld_getHelloWorld
(JNIEnv *env, jobject obj)
{
std::string str = "Hello World";
return (*env)->NewStringUTF(env,str.c_str()); //COMPILER ERROR
}
The compiler error is:
Error E2288 HelloWorld.cpp 10: Pointer to structure required on left
side of -> or ->* in function __stdcall
Java_HelloWorld_getHelloWorld(JNIEnv_ *,_jobject *)
I followed the example at the bottom of this page:
http://java.sun.com/docs/books/tutorial/native1.1/implementing/string.html
so I don't know what's going wrong. Can anyone help?
Thanks,
cpp