I have made a little program in java that accepts a string as a user input. Now i have made a dll writing its code in Visual C++. when i run my program from netbeans it displays this exception.
Exception in thread "main" java.lang.UnsatisfiedLinkError: Prompt.getLine(Ljava/lang/String;)Ljava/lang/String;
at Prompt.getLine(Native Method)
at Prompt.main(Prompt.java:19)
What problem is this. Need Help. Thanks
This is java code
public class Prompt {
/**
* @param args the command line arguments
*/
private native String getLine(String prompt);
public static void main(String[] args) {
// TODO code application logic here
Prompt p = new Prompt();
String input = p.getLine("Type a line:");
System.out.println("User Typed:" + input);
}
static {
System.loadLibrary("Prompt");
//System.load("C:/Program Files/Java/jdk1.6.0/bin/Prompt.dll");
}
}
and this is C++ Code
#include "stdafx.h"
#include "jni.h"
#include "jni_md.h"
JNIEXPORT jstring JNICALL Java_Prompt_getLine(JNIEnv *env, jobject obj, jstring prompt)
{
char buf[128];
const char *str;
str = env->GetStringUTFChars(prompt,0);
if (str == NULL) {
return NULL; /* OutOfMemoryError already thrown */
}
printf("%s", str);
env->ReleaseStringUTFChars(prompt, str);
/* We assume here that the user does not type more than
* 127 characters */
scanf("%s", buf);
return env->NewStringUTF(buf);
}