JNI library path

T

Tom

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");
 
J

Jean-Francois Briere

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
 
T

Tom

Jean-Francois Briere said:
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

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..
 
C

Chris Uppal

Jean-Francois Briere said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top