I just re-installed my OS some days ago,which contained Visual Studio.But I don't want to use the VS any more(at least in my computer) as the interminable installing process.Then I take Eclipse as my C/C++ IDE by MinGW and CDT.
My Java program need to load an DLL file which wrote by C.But when I generating the DLL file,I got some errors.It seems that the compiler cannot find the header files.
By the way,I just want to implement the hello-world program in C and invoke it in the Java program.
This is my Java testing program:
Code:
public class HelloWorld{ public native void printHelloWorld();
static{
System.loadLibrary("hello");
}
public static void main(String[] args){
new HelloWorld().printHelloWorld();
}
}
And this is the header file generating by "javah HelloWorld":
Code:
/* DO NOT EDIT THIS FILE - it is machine generated */#include <jni.h>
/* Header for class HelloWorld */
#ifndef _Included_HelloWorld
#define _Included_HelloWorld
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: HelloWorld
* Method: printHelloWorld
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_HelloWorld_printHelloWorld
(JNIEnv *, jobject);
#ifdef __cplusplus
}
#endif
#endif
And this is the C file:
Code:
#include "jni.h"#include "HelloWorld.h"
#include<stdio.h>
JNIEXPORT void JNICALL Java_HelloWorld_displayHelloWorld(JNIEnv *env, jobject obj)
{
printf("Hello world!\n");
return;
}
And this is the screenshot of error: