[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: libsvnjavahl with 0.9.21 on linux - help

From: Kurt Huwig <k.huwig_at_iku-ag.de>
Date: 2004-10-06 09:03:05 CEST

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Alwyn Schoeman wrote:
| In that case I do not know why it is not working as ldconfig -p shows
| all the libsvn*.so's installed...

~From the docs:

Each Java runtime environment provides its own mechanism that indicates
where to find shared libraries for native method implementations. The
platform-dependent wrapper script or application shell can use the
appropriate mechanism to indicate where shared libraries are located.

~ * Solaris:

~ The LD_LIBRARY_PATH environment variable defines a list of
directories that the Solaris VM searches for shared libraries.

You have to put the .so either in a path mentioned in LD_LIBRARY_PATH or
the 'lib/i386/' directory in your JRE directory.

The only other solution is to load the library by giving the path, i.e.
instead of

        System.loadLibrary("javahl");

you do a

        System.load("/path/to/my/library/libjavahl.so.0.0.0");

You can use a trick and include the library in the application's jar
file: you only have to write it into a temporary file and the load it:

try {
~ final File library = File.createTempFile("lib", ".so");
~ final InputStream is =
~ library.getClass().getResourceAsStream("/sponts.so");
~ if (is == null) {
~ logger.warning("cannot find JNI library in JAR");
~ } else {
~ final OutputStream os = new FileOutputStream(library);
~ try {
~ final byte[] buffer = new byte[8192];
~ for (int read; (read = is.read(buffer)) != -1; ) {
~ os.write(buffer, 0, read);
~ }
~ } finally {
~ os.close();
~ }
~ is.close();

~ System.load(library.getAbsolutePath());
~ library.deleteOnExit();

~ jniLibraryLoaded = true;
~ logger.log(Level.FINE, "JNI library loaded");
~ }

} catch (Throwable t) {
~ logger.log(Level.WARNING, "cannot load JNI library", t);
}

This code is Linux specific by using only '.so' filenames, but you can
easily write a Windos compatible version with a simple 'if'. The
important thing is to catch a Throwable instead of an Exception (I
learned this the hard way).
- --
Kurt Huwig iKu Systemhaus AG http://www.iku-ag.de/
Vorstand Am Römerkastell 4 Telefon 0681/96751-0
~ 66121 Saarbrücken Telefax 0681/96751-66
GnuPG 1024D/99DD9468 64B1 0C5B 82BC E16E 8940 EB6D 4C32 F908 99DD 9468
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFBY5ipTDL5CJndlGgRAvUDAJ9SJvU0H8PPbIpDUvk5aKFCOKO7EwCeMHnm
I+rqIZ4EZA0Y66GzPhqatCU=
=LreT
-----END PGP SIGNATURE-----
Received on Wed Oct 6 17:03:05 2004

This is an archived mail posted to the Subclipse Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.