Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / October 2006

Tip: Looking for answers? Try searching our database.

JNI library path

Thread view: 
Tom - 08 Oct 2006 05:33 GMT
i have create a dll (my.dll) for my java program to call the functions
in my.dll

It requires external dlls, b.dll, c.dl to do further processingl...

right now i am able to run my java program calling the function in
my.dll

however i need to put b.dll, c.dll into c:\windows\system32

i need to put all the dlls into one specific folder for easy
usage..instead of having b.dll, c.dll in c:\windows\system32, put all
dlls into c:\all-dll

how can i achieve this?

my.dll is called with this method
System.load("C:\\all-dll\my.dll");
Jean-Francois Briere - 08 Oct 2006 07:42 GMT
It,s better to do:

System.loadLibrary("my"); // no absolute path and no (OS-specific)
extension

And then do on execution:

java -Djava.library.path=C:\all-dll YourClass

Regards
Tom - 08 Oct 2006 10:50 GMT
> It,s better to do:
>
[quoted text clipped - 6 lines]
>
> Regards

is it possible to change the library path during runtime?
as such, i would read the library path from a config file and set the
library path in the program during runtime..
Chris Uppal - 08 Oct 2006 10:52 GMT
> System.loadLibrary("my"); // no absolute path and no (OS-specific)
> extension

Agreed.

> And then do on execution:
>
> java -Djava.library.path=C:\all-dll YourClass

Does that cause Windows to resolve a.dll and b.dll when they are loaded from
my.dll ?   I'm willing to believe it is (presumably the JVM must add
java.library.path to the Windows %Path%), but would be surprised even so.
(Unfortunately, it's too much effort to set up a test.)

What I would do is ensure that my.dll, a.dll, and b.dll were all on the
%Path% -- either by changing the %Path% or by finding somewhere suitable on the
%Path% for them to live.  In normal applications, the best place is in the same
directory as the application, but that might be awkward for Java (depending on
how the OP's deploying the program).

Another factor to consider is how my.dll is loading a.dll and b.dll.  If it is
loading them implicitly (say by using a .lib stub) then the OS and/or the stub
will look for the secondary DLLs.  But it's also possible that my.dll is
loading a.dll and b.dll from an explicitly defined location, in which case all
bets are off.

   -- chris


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.