System.load("...");

M

Michael Wiedmann

Do I have to configure - on a Unix-like system - the configuration file
of the dynamic loader (/etc/ld.so.conf) with the pathname of the shared
object to be loaded by System.load("...") or does the VM all by itself?

Example:

System.load(/path/to/file.so);

Michael
 
G

Gordon Beaton

Do I have to configure - on a Unix-like system - the configuration file
of the dynamic loader (/etc/ld.so.conf) with the pathname of the shared
object to be loaded by System.load("...") or does the VM all by itself?

Example:

System.load(/path/to/file.so);

No, you don't need to configure anything.

However if you use System.loadLibrary() instead, you only need to
specify an unadorned library name (i.e. without a path or any system
specific prefixes and suffixes) and the dynamic loader will find the
correct file using search rules specific to your system. This is more
flexible and portable.

On your Unix-like system, that means that you can either update
/etc/ld.so.conf, or set an environment variable such as
LD_LIBRARY_PATH before starting the application.

/gordon
 
M

Michael Wiedmann

Gordon Beaton wrote:
....
On your Unix-like system, that means that you can either update
/etc/ld.so.conf, or set an environment variable such as
LD_LIBRARY_PATH before starting the application.

And what would be the equivalent on a Windows (or even Mac OS X) system?

Michael
 
G

Gordon Beaton

Gordon Beaton wrote:
...

And what would be the equivalent on a Windows (or even Mac OS X) system?

Windows uses the PATH to find dlls.

AFAIK, the unix-like description holds for OS X as well, but read the
man page for ld or ld.so to be sure.

/gordon
 
T

Tor Iver Wilhelmsen

Michael Wiedmann said:
And what would be the equivalent on a Windows (or even Mac OS X) system?

The core is that Java uses the System property "java.library.path" to
look for the shared libraries; how this is initialized is system
dependent. But you can specify it yourself on the ocmmand line, e.g.

java -Djava.library.path=. -jar myapp.jar
 

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

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top