UnsatisfiedLinkError persists after much futzing
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Ralph_Cook
Posted On:   Sunday, June 21, 2009 07:22 PM

I am running eclipse 3.1.1; I downloaded a package to read serial ports that includes a DLL and the JNI structures to call it. If I run their jar I get something; it appears to be serial data from the device that is set to the wrong baud rate. So far, so good. When I put the project into eclipse and run it, I get "java.lang.UnsatisfiedLinkError: com.endgidea.winjcom.JcomDriver.nativeInitialize(I)V thrown while loading" The DLL file is in c:WINDOWS and c:WINDOWSSYSTEM32 In the debugger I looked at System.getProperty("java.library.path") and got C:Program FilesJavajre1.6.0_03 in;.;C:WINDOWSSunJava in;C:WINDOWSsystem32;C:WINDOWS;c:local;C:WINDOWSsystem32;C:WINDOWS;C   More>>

I am running eclipse 3.1.1; I downloaded a package to read serial ports that includes a DLL and the JNI structures to call it.


If I run their jar I get something; it appears to be serial data from the device that is set to the wrong baud rate. So far, so good.


When I put the project into eclipse and run it, I get "java.lang.UnsatisfiedLinkError: com.endgidea.winjcom.JcomDriver.nativeInitialize(I)V thrown while loading"


The DLL file is in c:WINDOWS and c:WINDOWSSYSTEM32


In the debugger I looked at System.getProperty("java.library.path") and got C:Program FilesJavajre1.6.0_03 in;.;C:WINDOWSSunJava in;C:WINDOWSsystem32;C:WINDOWS;c:local;C:WINDOWSsystem32;C:WINDOWS;C:WINDOWSSystem32Wbem;c:jse6 in;C:Program FilesIntelDMIX;C:Program FilesATI TechnologiesATI Control Panel;c:Program Filesvslickwin


The file does not exist in the ...jre1.6.0_03 in, nor in the ...SunJava in directory (which doesn't seem to exist).


In a DOS window, 'path' gives PATH=c:local;C:WINDOWSsystem32;C:WINDOWS;C:WINDOWSSystem32Wbem;c:jse6 in;C:Program FilesIntelDMIX;C:Program FilesATI TechnologiesATI Control Panel;c:Program Filesvslickwin


The code that does the loading is just:


System.loadLibrary(jcomNativeLibrary);


whre jcomNativeLibrary is a static string with the name of the DLL file. It does not have a .dll extension on it, nor any path information; it just translates to "winjcom".


I have tried using System.load("c:\WINDOWS\winjcom.dll") -- same result.


I have turned on -verbose in the eclipse JVM - after a trace statement from before the loadLibrary statement, the next thing verbose tells me is that it is loading the UnsatisfiedLinkError class.


The fact that the test program will run from the jar outside of eclipse suggests to me that there's nothing keeping the DLL from running; there is some problem loading this library from within eclipse. Can someone point me in the right direction here?


Also -- have tried it under java 1.6 (or 6) on eclipse and under 1.4; no difference. java -version on the command line where I can run it under DOS gives 1.6.0_13-b03


I then updated the code to this:

			
public void initialize()
{
if (debug) report (classname+"initialize native lib=" + jcomNativeLibrary);

// load native library
// System.loadLibrary(jcomNativeLibrary);
String tempJcomNativeLibrary = "c:\WINDOWS\winjcom.dll";
File file = new File(tempJcomNativeLibrary);
if (file.exists())
{
System.out.println("file has " + file.getAbsolutePath());
System.out.println("file can be executed? " + file.canExecute());
System.out.println("file can be read ? " + file.canRead());
System.out.println("file can be written ? " + file.canWrite());
System.out.println("loading " + tempJcomNativeLibrary);
System.load(file.toString());
}
else { System.out.println("Can't find file " + tempJcomNativeLibrary + " to load"); }

// Init the native part of the library
// the parameter is the debug mask, look at the source for the possible values
nativeInitialize(0x0);
}


With the following result:

			
JcomDriver.initialize native lib=winjcom
file has c:WINDOWSwinjcom.dll
file can be executed? true
file can be read ? true
file can be written ? true
loading c:WINDOWSwinjcom.dll
[Loaded java.lang.UnsatisfiedLinkError from C:Program FilesJavajre1.6.0_03lib
t.jar]
java.lang.UnsatisfiedLinkError: com.engidea.winjcom.JcomDriver.nativeInitialize(I)V thrown while loading


Anyone know anything else I can check? I'm stumped.    <<Less
About | Sitemap | Contact