我尝试使用Java运行C#方法。我做了以下代码来做到这一点。
Main.java
public class Main {
public native void printHello();
static {
System.loadLibrary("");
}
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
Main.h
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class Main */
#ifndef _Included_Main
#define _Included_Main
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: Main
* Method: printHello
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_Main_printHello(JNIEnv *env, jobject obj)
{
AfxMessageBox("Hello World from dll");
}
#ifdef __cplusplus
}
#endif
#endif
我尝试使用以下命令生成DLL
cl -I %java_home%\include -I %java_home%\include\win32 -LD Main.h Hello.dll
我收到以下错误
Main.h : fatal error LNK1107: invalid or corrupt file: cannot read at 0x188
我该如何解决这个问题?