Skip to Main Content

Java HotSpot Virtual Machine

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Help needed (the notorious java.lang.UnsatisfiedLinkError)

843829Sep 16 2008 — edited Jul 13 2009
Hello all.

I'm using Eclipse 3.4.0 on Windows and getting the following error when trying to call a function from a dll which is located in the java project(Test) folder:
Exception in thread "main" java.lang.UnsatisfiedLinkError: Test.hello()V
	at Test.hello(Native Method)
	at Test.main(Test.java:12)
Any thoughts about why this problem is happening will be very appreciated.

This is my simple code:
Test.java
public class Test {
	
	public native void hello();
	
	static {
		System.loadLibrary("hello");
	}

	public static void main(String[] args) {
	
		new Test().hello();
	}
}
test.cpp
#include <iostream>
#include "Test.h"

JNIEXPORT void JNICALL Java_Test_hello
  (JNIEnv *env, jobject obj)
{
	std::cout<<"Hello World!"<<std::endl;
}
Test.h
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class Test */

#ifndef _Included_Test
#define _Included_Test
#ifdef __cplusplus
extern "C" {
#endif
/*
 * Class:     Test
 * Method:    hello
 * Signature: ()V
 */
JNIEXPORT void JNICALL  Java_Test_hello
  (JNIEnv *, jobject);

#ifdef __cplusplus
}
#endif
#endif
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 10 2009
Added on Sep 16 2008
10 comments
685 views