List Info

Thread: Java Bindings on a Mac




Java Bindings on a Mac
user name
2007-02-04 10:59:12
I had to make some changes (sorry no diff available) to
"configure" in
0.9.9 of the bindings so that I could compile them for OS X
10.4.8.
Essentially I replaced the the paths to jni.h with
/System/Library/Frameworks/JavaVM.framework/Headers.  It
compiled
without error and created both libxapian_jni.so and
xapian_jni.jar in
the "built" subdirectory when I ran "make
install".

When I ran the example code (from the "java"
directory) I got the following:

$ java -Djava.library.path=built -classpath
built/xapian_jni.jar:. 
>       org.xapian.examples.SimpleIndex ./test.db index
words like java
Exception in thread "main"
java.lang.UnsatisfiedLinkError: no
xapian_jni in java.library.path
        at
java.lang.ClassLoader.loadLibrary(ClassLoader.java:1682)
        at java.lang.Runtime.loadLibrary0(Runtime.java:822)
        at java.lang.System.loadLibrary(System.java:992)
        at
org.xapian.XapianJNI.<clinit>(XapianJNI.java:44)
        at
org.xapian.WritableDatabase.<init>(WritableDatabase.ja
va:42)
        at
org.xapian.examples.SimpleIndex.main(SimpleIndex.java:44)

It did not make any difference when I set LD_LIBRARY_PATH to
the
absolute "built" path either.  I got the same
results.  I am using the
Apple Java 5 J2SE.  Has anyone gotten the bindings to work
under OS X?

-- 
john david schult
usa : georgia : buford
m: 404.510.5163

_______________________________________________
Xapian-devel mailing list
Xapian-devellists.xapian.org
http://lists.xapian.org/mailman/listinfo/xapian-devel

Re: Java Bindings on a Mac
user name
2007-02-04 12:30:15
Well, thanks to a colleague I figured it out...  The Apple
JVM looks
for libraries in
/System/Library/Frameworks/JavaVM.framework/Libraries/ and
does not
seem to care about -Djava.library.path or LD_LIBRARY_PATH. 
There is
probably some environment variable that it does examine, but
I stopped
trying to figure it out.

The solution was to:

- Copy built/libxapian_jni.so to
/System/Library/Frameworks/JavaVM.framework/Libraries/libxap
ian_jni.jnilib
(note the extension)

After that it worked as advertised...

$ java -version
java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build
1.5.0_06-113)
Java HotSpot(TM) Client VM (build 1.5.0_06-68, mixed mode,
sharing)

$ uname -a
Darwin apollo.local 8.8.2 Darwin Kernel Version 8.8.2: Thu
Sep 28
20:43:26 PDT 2006; rootnu-79
2.14.14.obj~1/RELEASE_I386 i386 i386

$ java -classpath built/xapian_jni.jar:.
org.xapian.examples.SimpleSearch ./test.db index words like
java
Found 4 matching documents using Xapian::Query((index OR
words OR like OR java))
25% [1] index
25% [2] words
25% [3] like
25% [4] java


On 2/4/07, John Schult <schultygmail.com> wrote:
> I had to make some changes (sorry no diff available) to
"configure" in
> 0.9.9 of the bindings so that I could compile them for
OS X 10.4.8.
> Essentially I replaced the the paths to jni.h with
> /System/Library/Frameworks/JavaVM.framework/Headers. 
It compiled
> without error and created both libxapian_jni.so and
xapian_jni.jar in
> the "built" subdirectory when I ran
"make install".
>
> When I ran the example code (from the "java"
directory) I got the following:
>
> $ java -Djava.library.path=built -classpath
built/xapian_jni.jar:. 
> >       org.xapian.examples.SimpleIndex ./test.db
index words like java
> Exception in thread "main"
java.lang.UnsatisfiedLinkError: no
> xapian_jni in java.library.path
>         at
java.lang.ClassLoader.loadLibrary(ClassLoader.java:1682)
>         at
java.lang.Runtime.loadLibrary0(Runtime.java:822)
>         at
java.lang.System.loadLibrary(System.java:992)
>         at
org.xapian.XapianJNI.<clinit>(XapianJNI.java:44)
>         at
org.xapian.WritableDatabase.<init>(WritableDatabase.ja
va:42)
>         at
org.xapian.examples.SimpleIndex.main(SimpleIndex.java:44)
>
> It did not make any difference when I set
LD_LIBRARY_PATH to the
> absolute "built" path either.  I got the same
results.  I am using the
> Apple Java 5 J2SE.  Has anyone gotten the bindings to
work under OS X?
>
> --
> john david schult
> usa : georgia : buford
> m: 404.510.5163
>


-- 
john david schult
usa : georgia : buford
m: 404.510.5163

_______________________________________________
Xapian-devel mailing list
Xapian-devellists.xapian.org
http://lists.xapian.org/mailman/listinfo/xapian-devel

Re: Re: Java Bindings on a Mac
country flaguser name
United Kingdom
2007-02-06 01:32:11
On Sun, Feb 04, 2007 at 01:30:15PM -0500, John Schult
wrote:
> Well, thanks to a colleague I figured it out...  The
Apple JVM looks
> for libraries in
> /System/Library/Frameworks/JavaVM.framework/Libraries/
and does not
> seem to care about -Djava.library.path or
LD_LIBRARY_PATH.  There is
> probably some environment variable that it does
examine, but I stopped
> trying to figure it out.

I'm not a Mac expert, but libtool seems to think OS X uses
DYLD_LIBRARY_PATH rather than LD_LIBRARY_PATH.

Does "make check" work in the java subdirectory of
the built source
tree?

> >Essentially I replaced the the paths to jni.h with
>
>/System/Library/Frameworks/JavaVM.framework/Headers.

When you say "essentially", was that the only
change?  If so, we should
be able to do that automatically for OS X.  And similarly
for the
installation location and different library extension.

Cheers,
    Olly

_______________________________________________
Xapian-devel mailing list
Xapian-devellists.xapian.org
http://lists.xapian.org/mailman/listinfo/xapian-devel

Re: Re: Java Bindings on a Mac
user name
2007-02-09 17:21:34
On 2/6/07, Olly Betts <ollysurvex.com> wrote:
> When you say "essentially", was that the only
change?  If so, we should
> be able to do that automatically for OS X.  And
similarly for the
> installation location and different library extension.

Yes, that was the only change.  I agree, configure could
certainly be
changed to make it work.  I just was not the right person
for that
particular job 

++john

_______________________________________________
Xapian-devel mailing list
Xapian-devellists.xapian.org
http://lists.xapian.org/mailman/listinfo/xapian-devel

Re: Re: Java Bindings on a Mac
country flaguser name
United Kingdom
2007-02-09 20:12:14
On Fri, Feb 09, 2007 at 06:21:34PM -0500, John Schult
wrote:
> On 2/6/07, Olly Betts <ollysurvex.com> wrote:
> >When you say "essentially", was that the
only change?  If so, we should
> >be able to do that automatically for OS X.  And
similarly for the
> >installation location and different library
extension.
> 
> Yes, that was the only change.  I agree, configure
could certainly be
> changed to make it work.  I just was not the right
person for that
> particular job 

That's OK - I'm happy to make the configure changes, but I
need to know
what tests are required.

I found this page on Apple's site which seems helpful:

http
://developer.apple.com/documentation/Java/Conceptual/Java14D
evelopment/05-CoreJavaAPIs/CoreJavaAPIs.html

Based on this, I think -Djava.library.path wasn't working
for you
because the extension was wrong (i.e. not .jnilib).

It also seems that /Library/Java/Extensions/ is the
appropriate place to
install rather than
/System/Library/Frameworks/JavaVM.framework/Libraries/
(presumably the latter is for stuff which is shipped with
the JVM).

I've now checked in changes so that on OS X configure should
find jni.h 
and "make install" should rename the built library
to .jnilib.  I've
also documented the installation location.

If you're able to test an SVN snapshot, you need 7612 or
later:

http://www.o
ligarchy.co.uk/xapian/trunk/

And "make check" should now work.

Cheers,
    Olly

_______________________________________________
Xapian-devel mailing list
Xapian-devellists.xapian.org
http://lists.xapian.org/mailman/listinfo/xapian-devel

Re: Re: Java Bindings on a Mac
user name
2007-02-09 20:37:41
On 2/9/07, Olly Betts <ollysurvex.com> wrote:
> It also seems that /Library/Java/Extensions/ is the
appropriate place to
> install rather than
/System/Library/Frameworks/JavaVM.framework/Libraries/
> (presumably the latter is for stuff which is shipped
with the JVM).

1. configure --with-java worked fine...

2. make ran fine

3. I defined DYLD_LIBRARY_PATH as
<full_path_to>/java/built and ran
make check.  It was successful.

4. I undefined  DYLD_LIBRARY_PATH and copied
java/built/libxapian_jni.jnilib to
/Library/Java/Extensions/.  A make
check was successful.

Looks like you can set the install path to
/Library/Java/Extensions.
Thanks and glad I could help out 

++john

_______________________________________________
Xapian-devel mailing list
Xapian-devellists.xapian.org
http://lists.xapian.org/mailman/listinfo/xapian-devel

Re: Re: Java Bindings on a Mac
country flaguser name
United Kingdom
2007-02-09 20:52:41
On Fri, Feb 09, 2007 at 09:37:41PM -0500, John Schult
wrote:
> On 2/9/07, Olly Betts <ollysurvex.com> wrote:
> >It also seems that /Library/Java/Extensions/ is the
appropriate place to
> >install rather than
/System/Library/Frameworks/JavaVM.framework/Libraries/
> >(presumably the latter is for stuff which is
shipped with the JVM).
> 
> 1. configure --with-java worked fine...
> 
> 2. make ran fine
> 
> 3. I defined DYLD_LIBRARY_PATH as
<full_path_to>/java/built and ran
> make check.  It was successful.
> 
> 4. I undefined  DYLD_LIBRARY_PATH and copied
> java/built/libxapian_jni.jnilib to
/Library/Java/Extensions/.  A make
> check was successful.

Does "make check" work without setting
DYLD_LIBRARY_PATH or copying
libxapian_jni.jnilib anywhere?  It should do...

> Looks like you can set the install path to
/Library/Java/Extensions.
> Thanks and glad I could help out 

We don't install the JNI library anywhere special on other
platforms, so
I think it's probably better to just document where to copy
it to if you
want it installed system-wide.  I'm open to persuasion
though,
especially if there's a suitable place to install on other
platforms too.

Cheers,
    Olly

_______________________________________________
Xapian-devel mailing list
Xapian-devellists.xapian.org
http://lists.xapian.org/mailman/listinfo/xapian-devel

Re: Re: Java Bindings on a Mac
user name
2007-02-09 21:39:30
On 2/9/07, Olly Betts <ollysurvex.com> wrote:

> Does "make check" work without setting
DYLD_LIBRARY_PATH or copying
> libxapian_jni.jnilib anywhere?  It should do...

No

> We don't install the JNI library anywhere special on
other platforms, so
> I think it's probably better to just document where to
copy it to if you
> want it installed system-wide.  I'm open to persuasion
though,
> especially if there's a suitable place to install on
other platforms too.

Documentation should be fine, I think.

++john

_______________________________________________
Xapian-devel mailing list
Xapian-devellists.xapian.org
http://lists.xapian.org/mailman/listinfo/xapian-devel

[1-8]

about | contact  Other archives ( Real Estate discussion Medical topics )