I am trying to setup a simple dll that will allow me to run C++ code from Java, to start I chose to create the function HelloWorld, I can get the library to compile and load but when Java calls the native method "hello()" it throws the exception java.lang.UnsatisfiedLinkError.
How can I fix this?
My Files:
Helloworld.cpp
#include "Helloworld.h"
JNIEXPORT void JNICALL Java_JPokerBot_Process_hello (JNIEnv *, jobject) {
printf("Hello world!\n");
return;
}
Helloworld.h
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class JPokerBot_Process */
#ifndef _Included_JPokerBot_Process
#define _Included_JPokerBot_Process
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: helloworld
* Method: hello
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_helloword_hello
(JNIEnv *, jobject);
#ifdef __cplusplus
}
#endif
#endif
helloworld.java
import java.util.*;
class helloworld {
//Native method declaration
public native void hello();
public static void main(String args[]) {
try {
helloworld hello = new helloworld();
helloworld.hello();
} catch(UnsatisfiedLinkError e) {
System.out.println(e);
}
}
}