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!

System.loadLibrary() not using java.library.path

843829Jul 12 2004 — edited Jul 13 2004
I am having a very bizzare problem which I am hoping someone might be able to enlighten me on. I basically have two files: natvie.jar and native.dll. Native.jar contains my class that loads the DLL using System.loadLibrary("native") call.

I have tried the following:

Scenerio 1 - Native jar is in the webapp and the library is in system32. Library loads fine and I can read the mac address. (just as a note always work from a comand line test class) *** WORKED ***
------------------------------------------------
server/webapps/Test1/WEB-INF/lib/native.jar
c:/windows/system32/native.dll
java.library.path=C:/windows/system32;.;c:/windows;...


Scenario 2 - I moved Native.jar into the servers/lib directory, I did not move the DLL it is still in System32. Library is not found and I get a UnsatifiedLinkError. *** FAILED ***
----------------------------------------------
server/lib/native.jar
c:/windows/system32/native.dll
java.library.path=C:/windows/system32;.;c:/windows;...


Scenario 3 - I move the Native.jar to the jre/lib/endorsed directory, I did not move the DLL. I once again get library not found.
----------------------------------------------
c:/java/jre/lib/endored/native.jar
c:/windows/system32/native.dll
java.library.path=C:/windows/system32;.;c:/windows;...


If I use System.load("c:\\windows\\system32\\native.dll") to load the library it works in all 2 scenarios.

The reason I need to move the JAR up above the web application is because I have a second web application Test2 which must also use the DLL. If I put the jar into both webapps I get a UnsatifiedLinkError "Library already Loaded" error.

Does anyone have any idea why this is happening? I have already blown a solid day messing with this and am clueless!

Thanks
Fran
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 10 2004
Added on Jul 12 2004
4 comments
1,473 views