Hi,
I want to use Ant to compile and run Java/JNI code. And I have a problem
when I want to set the java.libray.path.
I use for this e-mail Windows syntax/terminology.
Let's say we have : myLibraryPath is my dymamic library path (where the
ClassLoader should be able to load the dll).
To be sure, when I run that :
> SET PATH=%PATH%;myLibraryPath
> ant testJNICode
it works (hopefully).
But, if I run
> ant testJNICode
I got a java.lang.UnsatisfiedLinkError: no myJNIlibrary in java.library.path
at java.lang.ClassLoader.loadLibrary(Unknown Source)...
(of course myJNIlibrary.dll is in myLibraryPath)
So I want to set in my build.xml the path where the Java classloader will
find DLL - to be able for example to switch from native configurations
(Debug or Release) according to some properties.
As I cannot override the "java.library.path", how can I do that from Ant ?
I tried many things but did have the result I wanted :
============ 1 =============
I tried a
<sysproperty key="java.library.path"
path="${java.library.path};${myLibraryPath}" />
on the java task.
But it doesn't work. :-(
============ 2 =============
I tried to use antcall param tag.
<target name="testJNICode2">
<antcall target="testJNICode">
<param name="java.library.path"
value="${java.library.path};${myLibraryPath}" />
</antcall>
</target>
<target name="testJNICode">
<!-- to debug -->
<echo message="java.library.path = ${java.library.path}" />
<java classname="myClassThatUsesJNI">
</java>
</target>
As a result : echo write a correct java.library.path (with myLibraryPath in
it !) but the java task still doesn't work :-( even if the java task is
forked...
============ 3 =============
When I use a dirty exec task like that, it works but I don't like that - it
is not good for my cross-platform environment I want to use.
<target name="testJNICode3">
<exec executable="java" >
<env key="PATH" path="${myLibraryPath}" />
<env key="CLASSPATH" path=".. myclasspath...." />
<arg line="myClassThatUsesJNI" />
</exec>
</target>
============ theEnd ========
Can someone help me on a such problem ?
Thanks, and sorry for the big e-mail.
Yannick
---
Yannick Le Duc - [EMAIL PROTECTED]
Envivio
Portland, OR