JNI loadLibary "Can't find dependent libraries"

cocojack42

Mitglied
Schönen guten Abend,

ich habe versucht mit dem Java Native Interface zu arbeiten und eine einfache HelloWorld zu schreiben. Leider bekomme ich immer folgende Fehlermeldung wenn ich auf Run klicke:

Code:
Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\Windows\GnublinIO.dll: Can't find dependent libraries
	at java.lang.ClassLoader$NativeLibrary.load(Native Method)
	at java.lang.ClassLoader.loadLibrary1(Unknown Source)
	at java.lang.ClassLoader.loadLibrary0(Unknown Source)
	at java.lang.ClassLoader.loadLibrary(Unknown Source)
	at java.lang.Runtime.loadLibrary0(Unknown Source)
	at java.lang.System.loadLibrary(Unknown Source)
	at de.tec.gnublin.nativeclass.GnublinIO.<clinit>(GnublinIO.java:6)
	at de.tec.gnublin.io.Main.main(Main.java:8)

ich habe folgendes gemacht:

1. genutztes Tutorial : Java Blog Buch : 19.02 Hello (JNI) World
2. Änderungen an der jni_md.h : Building JNI-based Java Applications under Linux and Cygwin | Michael J. Hammel - The Graphics Muse
3. Compiler cygwin mit folgenden Parametern:
gcc -I"/cygdrive/c/Program Files/Java/jdk1.7.0_40/include/win32" -I"/cygdrive/c/Program Files/Java/jdk1.7.0_40/include" -I"/cygdrive/d/Entwicklung/Java/workspace/GnublinIoClient/src" -Wl,--add-stdcall-alias -shared -m64 -o GnublinIO.dll de_tec_gnublin_nativeclass_GnublinIO.cpp

4. Kopieren der GnublinIO.dll nach C:\Windows\

Ich arbeite auf Windows7-64 Bit

Code der GnublinIO.class:

Code:
public class GnublinIO {
	public static native void helloWorld();
	static{
		System.loadLibrary("GnublinIO");
	}
	
}

Code der de_tec_gnublin_nativeclass_GnublinIO.cpp
Code:
#include <jni.h>
#include <stdio.h>
#include "de_tec_gnublin_nativeclass_GnublinIO.h"

JNIEXPORT void JNICALL Java_de_tec_gnublin_nativeclass_GnublinIO_helloWorld(JNIEnv *env, jclass cls)	{
	 printf("Hello World\n");
	 return;
} // mit leerzeichen am ende!

und noch eben die java main:

Code:
public static void main(String[] args) {
		GnublinIO.helloWorld();
	}


Wenn ich die dll lösche bekomme ich eine andere Fehlermeldung. Aus dem Exception-Text entnehme ich, dass er irgendwelche aufbauenden Bibliotheken nicht finden kann, nur leider finde ich nicht welche.

Ich hoffe ich konnte mich verständlich ausdrücken und hoffe auf eure Hilfe.

lg Coco
 

cocojack42

Mitglied
Ich hab noch ein wenig dran rumgewerkelt, bekomme jetzt jedoch folgende Fehlermeldung:

#
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00000001800f2fb9, pid=1264, tid=4468
#
# JRE version: Java(TM) SE Runtime Environment (7.0_40-b43) (build 1.7.0_40-b43)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (24.0-b56 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# C [cygwin1.dll+0xb2fb9]
#
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# D:\Entwicklung\Java\workspace\GnublinIoClient\hs_err_pid1264.log
#
# If you would like to submit a bug report, please visit:
# HotSpot Virtual Machine Error Reporting Page
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

Hier der Inhalt der Log Datei:
Code:
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00000001800f2fb9, pid=1264, tid=4468
#
# JRE version: Java(TM) SE Runtime Environment (7.0_40-b43) (build 1.7.0_40-b43)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (24.0-b56 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# C  [cygwin1.dll+0xb2fb9]
#
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.sun.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

---------------  T H R E A D  ---------------

Current thread (0x0000000001f1d800):  JavaThread "main" [_thread_in_native, id=4468, stack(0x0000000002030000,0x0000000002130000)]

siginfo: ExceptionCode=0xc0000005, reading address 0xffffffffffffffff

Registers:
RAX=0x00000000002324c2, RBX=0x0000000000000001, RCX=0x00000000002324c2, RDX=0x0050005c003a0043
RSP=0x000000000212f390, RBP=0x000000000212f470, RSI=0x000000000212f3fc, RDI=0x000000000212f3fc
R8 =0x000000000212f3fc, R9 =0x8080808080808080, R10=0xfefefefefefefeff, R11=0x000000045084109c
R12=0x0000000000000000, R13=0x000000077b24be40, R14=0x000000000212f508, R15=0x0000000001f1d800
RIP=0x00000001800f2fb9, EFLAGS=0x0000000000010202

Top of Stack: (sp=0x000000000212f390)
0x000000000212f390:   000000000212f550 000000005a2ab3b8
0x000000000212f3a0:   0000000001f1d800 000000000212f508
0x000000000212f3b0:   000000077b24be40 000000000212d61a
0x000000000212f3c0:   000000000212d440 00000001801756d3
0x000000000212f3d0:   0000000001f1dfd8 0000000450841080
0x000000000212f3e0:   000000000212f4e8 0000000001f1d800
0x000000000212f3f0:   0000000000000000 0000000001f1d800
0x000000000212f400:   000000000212f410 0000000c00000002
0x000000000212f410:   0000000450843030 000000000000000b
0x000000000212f420:   0000000180252450 0000000000000001
0x000000000212f430:   000000077b24be40 0000000001f1d800
0x000000000212f440:   0000000000000000 00000001801130ab
0x000000000212f450:   0000000001f1e000 0000000001f1d800
0x000000000212f460:   000000077b24be40 0000000000000000
0x000000000212f470:   000000000212f4e8 0000000002142af0
0x000000000212f480:   0000000001f1d9e8 000000000212f508 

Instructions: (pc=0x00000001800f2fb9)
0x00000001800f2f99:   1f 84 00 00 00 00 00 56 53 48 83 ec 28 89 cb 48
0x00000001800f2fa9:   89 d6 e8 30 31 04 00 48 8b 10 49 89 f0 48 89 c1
0x00000001800f2fb9:   4c 8b 4a 30 89 da 48 83 c4 28 5b 5e 49 ff e1 0f
0x00000001800f2fc9:   1f 84 00 00 00 00 00 56 53 48 83 ec 28 89 cb 48 


Register to memory mapping:

RAX=0x00000000002324c2 is an unknown value
RBX=0x0000000000000001 is an unknown value
RCX=0x00000000002324c2 is an unknown value
RDX=0x0050005c003a0043 is an unknown value
RSP=0x000000000212f390 is pointing into the stack for thread: 0x0000000001f1d800
RBP=0x000000000212f470 is pointing into the stack for thread: 0x0000000001f1d800
RSI=0x000000000212f3fc is pointing into the stack for thread: 0x0000000001f1d800
RDI=0x000000000212f3fc is pointing into the stack for thread: 0x0000000001f1d800
R8 =0x000000000212f3fc is pointing into the stack for thread: 0x0000000001f1d800
R9 =0x8080808080808080 is an unknown value
R10=0xfefefefefefefeff is an unknown value
R11=0x000000045084109c is an unknown value
R12=0x0000000000000000 is an unknown value
R13=0x000000077b24be40 is an oop
{method} 
 - klass: {other class}
R14=0x000000000212f508 is pointing into the stack for thread: 0x0000000001f1d800
R15=0x0000000001f1d800 is a thread


Stack: [0x0000000002030000,0x0000000002130000],  sp=0x000000000212f390,  free space=1020k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [cygwin1.dll+0xb2fb9]
j  de.tec.gnublin.nativeclass.GnublinIO.helloWorld()V+0
j  de.tec.gnublin.io.Main.main([Ljava/lang/String;)V+3
v  ~StubRoutines::call_stub

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j  de.tec.gnublin.nativeclass.GnublinIO.helloWorld()V+0
j  de.tec.gnublin.io.Main.main([Ljava/lang/String;)V+3
v  ~StubRoutines::call_stub

---------------  P R O C E S S  ---------------

Java Threads: ( => current thread )
  0x000000000a5f1000 JavaThread "Service Thread" daemon [_thread_blocked, id=768, stack(0x000000000bc40000,0x000000000bd40000)]
  0x000000000a5f0000 JavaThread "C2 CompilerThread1" daemon [_thread_blocked, id=4308, stack(0x000000000c060000,0x000000000c160000)]
  0x000000000a5ee000 JavaThread "C2 CompilerThread0" daemon [_thread_blocked, id=3596, stack(0x000000000bef0000,0x000000000bff0000)]
  0x000000000a5ec800 JavaThread "Attach Listener" daemon [_thread_blocked, id=1244, stack(0x000000000bdc0000,0x000000000bec0000)]
  0x000000000a5e5800 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=1160, stack(0x000000000bad0000,0x000000000bbd0000)]
  0x000000000a58d800 JavaThread "Finalizer" daemon [_thread_blocked, id=4272, stack(0x000000000b820000,0x000000000b920000)]
  0x000000000a58a000 JavaThread "Reference Handler" daemon [_thread_blocked, id=5048, stack(0x000000000b960000,0x000000000ba60000)]
=>0x0000000001f1d800 JavaThread "main" [_thread_in_native, id=4468, stack(0x0000000002030000,0x0000000002130000)]

Other Threads:
  0x000000000a586000 VMThread [stack: 0x000000000b6c0000,0x000000000b7c0000] [id=1536]
  0x000000000a5f3000 WatcherThread [stack: 0x000000000c310000,0x000000000c410000] [id=4232]

VM state:not at safepoint (normal execution)

VM Mutex/Monitor currently owned by a thread: None

Heap
 PSYoungGen      total 38912K, used 675K [0x00000007d5600000, 0x00000007d8100000, 0x0000000800000000)
  eden space 33792K, 2% used [0x00000007d5600000,0x00000007d56a8fc8,0x00000007d7700000)
  from space 5120K, 0% used [0x00000007d7c00000,0x00000007d7c00000,0x00000007d8100000)
  to   space 5120K, 0% used [0x00000007d7700000,0x00000007d7700000,0x00000007d7c00000)
 ParOldGen       total 87040K, used 0K [0x0000000780200000, 0x0000000785700000, 0x00000007d5600000)
  object space 87040K, 0% used [0x0000000780200000,0x0000000780200000,0x0000000785700000)
 PSPermGen       total 21504K, used 2352K [0x000000077b000000, 0x000000077c500000, 0x0000000780200000)
  object space 21504K, 10% used [0x000000077b000000,0x000000077b24c160,0x000000077c500000)

Card table byte_map: [0x0000000005130000,0x0000000005560000] byte_map_base: 0x0000000001558000

Polling page: 0x0000000000100000

Code Cache  [0x0000000002130000, 0x00000000023a0000, 0x0000000005130000)
 total_blobs=164 nmethods=0 adapters=133 free_code_cache=48774Kb largest_free_block=49945280

Compilation events (0 events):
No events

GC Heap History (0 events):
No events

Deoptimization events (0 events):
No events

Internal exceptions (3 events):
Event: 0.028 Thread 0x0000000001f1d800 Threw 0x00000007d560afb0 at C:\jdk7u2_64p\jdk7u40\hotspot\src\share\vm\prims\jni.cpp:3991
Event: 0.063 Thread 0x0000000001f1d800 Threw 0x00000007d564aa68 at C:\jdk7u2_64p\jdk7u40\hotspot\src\share\vm\prims\jvm.cpp:1244
Event: 0.068 Thread 0x0000000001f1d800 Threw 0x00000007d56504f0 at C:\jdk7u2_64p\jdk7u40\hotspot\src\share\vm\prims\jvm.cpp:1244

Events (10 events):
Event: 0.067 loading class 0x0000000001e9f710
Event: 0.067 loading class 0x0000000001e9f710 done
Event: 0.067 loading class 0x0000000001e9f7a0
Event: 0.067 loading class 0x0000000001e9f7a0 done
Event: 0.067 loading class 0x0000000001e6fa90
Event: 0.067 loading class 0x0000000001e6fa90 done
Event: 0.068 loading class 0x0000000001e58810
Event: 0.068 loading class 0x0000000001e58810 done
Event: 0.068 loading class 0x000000000a5f20d0
Event: 0.068 loading class 0x000000000a5f20d0 done


Dynamic libraries:
0x000000013fbf0000 - 0x000000013fc23000 	C:\Program Files\Java\jre7\bin\javaw.exe
0x0000000077370000 - 0x0000000077519000 	C:\Windows\SYSTEM32\ntdll.dll
0x0000000077150000 - 0x000000007726f000 	C:\Windows\system32\kernel32.dll
0x000007fefd620000 - 0x000007fefd68b000 	C:\Windows\system32\KERNELBASE.dll
0x000007fefda40000 - 0x000007fefdb1b000 	C:\Windows\system32\ADVAPI32.dll
0x000007fefef50000 - 0x000007fefefef000 	C:\Windows\system32\msvcrt.dll
0x000007feff1e0000 - 0x000007feff1ff000 	C:\Windows\SYSTEM32\sechost.dll
0x000007feff470000 - 0x000007feff59d000 	C:\Windows\system32\RPCRT4.dll
0x0000000077270000 - 0x000000007736a000 	C:\Windows\system32\USER32.dll
0x000007fefd9d0000 - 0x000007fefda37000 	C:\Windows\system32\GDI32.dll
0x000007feff150000 - 0x000007feff15e000 	C:\Windows\system32\LPK.dll
0x000007fefdf10000 - 0x000007fefdfd9000 	C:\Windows\system32\USP10.dll
0x000007fefbd70000 - 0x000007fefbf64000 	C:\Windows\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.7601.17514_none_fa396087175ac9ac\COMCTL32.dll
0x000007feff160000 - 0x000007feff1d1000 	C:\Windows\system32\SHLWAPI.dll
0x000007fefeff0000 - 0x000007feff01e000 	C:\Windows\system32\IMM32.DLL
0x000007fefee40000 - 0x000007fefef49000 	C:\Windows\system32\MSCTF.dll
0x000000005fd60000 - 0x000000005fe31000 	C:\Program Files\Java\jre7\bin\msvcr100.dll
0x000000005a1a0000 - 0x000000005a969000 	C:\Program Files\Java\jre7\bin\server\jvm.dll
0x000007fef7e50000 - 0x000007fef7e59000 	C:\Windows\system32\WSOCK32.dll
0x000007feff420000 - 0x000007feff46d000 	C:\Windows\system32\WS2_32.dll
0x000007fefee10000 - 0x000007fefee18000 	C:\Windows\system32\NSI.dll
0x000007fef9350000 - 0x000007fef938b000 	C:\Windows\system32\WINMM.dll
0x0000000077530000 - 0x0000000077537000 	C:\Windows\system32\PSAPI.DLL
0x0000000060e20000 - 0x0000000060e2f000 	C:\Program Files\Java\jre7\bin\verify.dll
0x000000005fd30000 - 0x000000005fd58000 	C:\Program Files\Java\jre7\bin\java.dll
0x000000005fd10000 - 0x000000005fd25000 	C:\Program Files\Java\jre7\bin\zip.dll
0x0000000450840000 - 0x0000000450857000 	D:\Entwicklung\Java\workspace\GnublinIoClient\src\GnublinIO.dll
0x0000000180040000 - 0x00000001805e0000 	D:\Entwicklung\cygwin64\bin\cygwin1.dll
0x000007fefadc0000 - 0x000007fefaee5000 	C:\Windows\system32\dbghelp.dll

VM Arguments:
jvm_args: -Dfile.encoding=Cp1252 
java_command: de.tec.gnublin.io.Main
Launcher Type: SUN_STANDARD

Environment Variables:
PATH=C:\Windows\System32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files\Java\jdk1.7.0_40\bin;D:\Entwicklung\cygwin64\bin
USERNAME=Coco
OS=Windows_NT
PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 37 Stepping 5, GenuineIntel



---------------  S Y S T E M  ---------------

OS: Windows 7 , 64 bit Build 7601 Service Pack 1

CPU:total 4 (2 cores per cpu, 2 threads per core) family 6 model 37 stepping 5, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3, sse4.1, sse4.2, popcnt, ht, tsc, tscinvbit

Memory: 4k page, physical 8379508k(5171168k free), swap 16757152k(13075744k free)

vm_info: Java HotSpot(TM) 64-Bit Server VM (24.0-b56) for windows-amd64 JRE (1.7.0_40-b43), built on Aug 26 2013 22:38:32 by "java_re" with unknown MS VC++:1600

time: Sun Nov 17 18:47:54 2013
elapsed time: 0 seconds


Ich habe noch statt System.loadLibrary(...) System.load("D:/Entwicklung/Java/workspace/GnublinIoClient/src/GnublinIO.dll"); genutzt, damit ich meine Daten direkt im workspace habe.

Hat auch nichts geändert, als ich es in den Windows-Ordner gelegt habe.
 

cocojack42

Mitglied
Ich habe mir Visual-Studio heruntergeladen und es für x64 compiliert, jetzt funktioniert alles wunderbar.

Scheinbar habe ich den Compiler falsch konfiguriert. Ich habe leider auch keine Ahnung was ich falsch gemacht habe, aber das ist auch nicht so wichtig.

Trotzdem vielen dank fürs lesen.

lg Coco
 
Ähnliche Java Themen
  Titel Forum Antworten Datum
D Selenium - cannot find Chrome binary Allgemeine Java-Themen 6
Kirby.exe Union Find Datenstruktur Allgemeine Java-Themen 27
bueseb84 Java : Cannot find Symbol Allgemeine Java-Themen 7
C Compiler-Fehler Cannot find symbol bei Hat-Beziehungen Allgemeine Java-Themen 5
P Find Bugs plugin Allgemeine Java-Themen 2
P JDK installieren Error: Could not find or load main class HelloWorld.java Allgemeine Java-Themen 3
S String mit Matcher.find durchsuchen und ausgeben Allgemeine Java-Themen 7
Phash Can't find Main Class Allgemeine Java-Themen 4
N Runtime.getRuntime().exec Problem mit find Allgemeine Java-Themen 3
S lp_solve mit Java nutzen - Can't find dependent libraries Allgemeine Java-Themen 8
127.0.0.1 Methodenaufruf -cannot find symbol- Allgemeine Java-Themen 14
X Could not find the main class programm will exit (textdokument) Allgemeine Java-Themen 3
S Could not find the main class Allgemeine Java-Themen 7
B Mal wieder "Could not find the main class" Allgemeine Java-Themen 3
C Could not find the main class. Allgemeine Java-Themen 15
nrg Find and replace Text docx Allgemeine Java-Themen 6
A Could not find main class: start Allgemeine Java-Themen 5
hdi Could not find main class? Allgemeine Java-Themen 8
B Cannot find main-claas... Allgemeine Java-Themen 21
P Java Editor Could not find the main class GUI. Programm will exit. Allgemeine Java-Themen 3
Tobse Cannot find symbol : construktor --- Deklariert! Allgemeine Java-Themen 9
D 'InputStreamReader' & 'BufferedReader' führen zu "cannot find symbol"-Fehler Allgemeine Java-Themen 3
BattleMaster246 Could not find the Main class Allgemeine Java-Themen 30
N Probleme mit .jar 'Could not find main class' Allgemeine Java-Themen 3
B cannot find Symbol Allgemeine Java-Themen 2
borobudur Find a AWT frame in SWT Allgemeine Java-Themen 4
A Problem mit StringBuilder delete - find den Fehler nicht Allgemeine Java-Themen 9
N Eclipse 3.4(Ganymede) "find references in workspace&quo Allgemeine Java-Themen 4
V JNI Can't find dependent libraries Allgemeine Java-Themen 4
G "Could not find the main class. Program will exit" Allgemeine Java-Themen 20
R Ausführen von *.JAR || "Could not find main class" Allgemeine Java-Themen 7
I "Could not find the main class. Program will exit" Allgemeine Java-Themen 6
B Could not find the main class Allgemeine Java-Themen 2

Ähnliche Java Themen

Neue Themen


Oben