Chris,

>
> This may seem like a very strange request, and it  probably is.
>
> I have some Inline Java in my perl program. I would like to load some
native
> C libraries (.so). I compiled Inline Java without the JNI extensions, when
I
> triid, it complained about the fact that it couldn't find jni.h in my JDK.
> When I run my program now, I get this
>

When you opt not to install the JNI extension, there should be no questions
about .h
files and there should be no C code compiled. If so send me the output of
"perl Makefile.PL J2SDK=..." and I'll take a look at it.

> This is what I get when I use the loadLibrary method on a Runtime
instance.
>
> Unexpected exception of type 'java.lang.UnsatisfiedLinkError': no
> <libraryname>.so in java.library.path at
> /usr/lib/perl5/site_perl/5.8.0/Inline/Java/Object.pm line 48
>
> When I use the full path, with the load method, the call works to load the
> library but the first call to a method throws
> java.lang.UnsatisfiedLinkError.
>
> I have tried adding java.library.path as an EXTRA_JAVA_ARGS
>
> use Inline Java => <<'END_OF_JAVA_CODE',EXTRA_JAVA_ARGS =>
> '-Djava.library.path=/lib' ;
> ...

For System.loadLibrary() to work, you must add your directory to
LD_LIBRARY_PATH
so that the JVM will know where to look for your shared object.Your shared
object must also
be called libxxx.so, and you must call System.loadLibrary("xxx") (no "lib"
and no ".so").

>
> Before I go any further I would like to know
>
> 1. Is it going to be possible, to call methods in my .so files with Inline
> Java ?

I don't see why not. Inline::Java should see them as just regular Java
methods.

> 2. Will I have to compile in JNI support ? Where should the jni.h be ? I
> installed the full 1.4.2 JDK from Sun.

It should work both ways (so, no, you should not need to build or use
Inline::Java's JNI
extension to do what you are trying to do).

> 3. How can I get loadLibrary to recognise my java.library.path and why
won't
> the call to the method work when I use load ?

See above.

>
> I am on RedHat Linux 9.0.
>
> Thanks
>
>
> Chris Faulkner

Cheers,

Patrick

Reply via email to