Hallo,
mit Java komme ich inzwischen (meistens) ganz gut zurecht, nun wollte ich mir mal das einbinden von nativen libs anschauen (in meinen fall dll´s)
Ich habe zu anfang mal einen code kopiert, der fertig war und kriege beim kompilieren Fehler, nachfolgend der Code hoffe mir kann wer helfen.
Java code:
HelloWorld.h:
C Code (der auch problemlos zur dll compiliert wird)
Name der dll : test.dll
Hier der Fehler, denn ich da von eclipse kriege:
mit Java komme ich inzwischen (meistens) ganz gut zurecht, nun wollte ich mir mal das einbinden von nativen libs anschauen (in meinen fall dll´s)
Ich habe zu anfang mal einen code kopiert, der fertig war und kriege beim kompilieren Fehler, nachfolgend der Code hoffe mir kann wer helfen.
Java code:
Java:
package de.home.jni.basics;
class HelloWorld {
public native void displayHelloWorld();
public static void main(String[] args) {
System.loadLibrary("test");
new HelloWorld().displayHelloWorld();
}
}
HelloWorld.h:
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: displayHelloWorld
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_HelloWorld_displayHelloWorld
(JNIEnv *, jobject);
#ifdef __cplusplus
}
#endif
#endif
C Code (der auch problemlos zur dll compiliert wird)
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;
}
Name der dll : test.dll
Hier der Fehler, denn ich da von eclipse kriege:
Code:
java.lang.NoClassDefFoundError: and
Caused by: java.lang.ClassNotFoundException: and
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Exception in thread "main"