#ifndef _Included_com_hello_HelloWorld
#define _Included_com_hello_HelloWorld
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: com_hello_HelloWorld
* Method: hello
* Signature: (Ljava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_com_hello_HelloWorld_hello
(JNIEnv *, jobject, jstring);
#ifdef __cplusplus
}
#endif
#endif
JNIHelloWorld.cpp:
// JNIHelloWorld.cpp : Defines the entry point for the DLL application.
//
#include "stdafx.h"
#include "com_hello_HelloWorld.h"
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
JNIEXPORT void JNICALL Java_com_hello_HelloWorld_hello
(JNIEnv *, jobject, jstring)
{
printf("I am in C++!\n");
return;
}
可以看到,我们在Java中,调用C++的方法成功!
至此,一个完整的HelloWorld版本的JNI过程,就完成了。
用Pthreads进行共享内存编程----HelloWorld
Hadoop实例之HelloWorld