ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dominique Devienne <>
Subject RE: UnsatisfiedLinkError when invoking native library using ant
Date Wed, 09 Jun 2004 21:44:27 GMT
> From: Jane Young [mailto:jane.young@Sun.COM]
> I have a custom ant task which uses a native library to retrieve os
> system environments.

If that's all you do, Ant already has access to env. vars, so you don't need
to deal with JNI issues. See <property environment="env" />

> In this task, I've set the location of the native
> library in  java.library.path, java.class.path using
> System.setProperty()  and also set the location of the library in
> AntClassLoader class.  When invoking the native code, I get a
> UnsatifiedLinkError.  There are 2 ways I can get around this: 1) set
> environment LB_LIBRARY_PATH to contain  the location of the native
> library or 2) set ANT_OPTS to -Djava.library.path=<location of native
> library>.
> Is there a way to get around this in the code without setting the
> environment?   If I set it in java.library.path in the code, shouldn't
> that take care of it?

There are some Java System properties which are used very early during the
VM initialization, and it's likely this is one of them. I think you can load
a JNI library using an full pathname, but if that native lib has any
dependencies, then these need to be located using the platform-specific
mechanism, Path or LD_LIBRARY_PATH or whatever. Even java.library.path
doesn't help here. --DD

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message