views:

287

answers:

2

Hi.

I need to set java -Djava.library.path=/some/path and I want to do it when I am running my ant script, building my jar.

I think I have to use

<sysproperty key="java.library.path" value="/some/path"/>

but it doesnt work. I cannot make the syntax work. The only thing I have Googled and found is sysproperty in conjunction with

 <java classname>

but that doesnt make any sense to me.

I am not sure if this is relevant, but I am using ant to create a ear and deploying this ear in JBoss.

A: 

did you try to run

ant -Djava.library.path=/some/path ...  ?
Omry
No I haven't tried this. But I am running ant inside eclipse. Not sure how I can add that parameter in eclipse.
Shervin
I would much rather avoid doing it like that if I have a choice
Shervin
Ok, I tried what you suggested, and it still didn't work.I still get don't get the value I added when I print out System.getProperty("java.library.path"). Just much other things.
Shervin
what put those "much other things" there? normally this is not set.
Omry
I don't know. I'm guessing JBoss.The value I have now is: 11:44:55,656 INFO [OpenOfficeService] java.library.path is: /usr/lib/jvm/jdk1.5.0_22/jre/lib/i386/server:/usr/lib/jvm/jdk1.5.0_22/jre/lib/i386:/usr/lib/jvm/jdk1.5.0_22/jre/../lib/i386:/usr/lib/jvm/java-6-sun-1.6.0.15/jre/lib/i386/client:/usr/lib/jvm/java-6-sun-1.6.0.15/jre/lib/i386:/usr/lib/xulrunner-addons:/usr/lib/xulrunner-addonsHowever, I would like to add /usr/lib/ure/lib
Shervin
if you figure out who sets this value, you will have a chance to configure it to set something else.how exactly are you running ant?
Omry
A: 

I found out how I can solve this.

Seems like since we are using ant to create and deploy our application in a Application Server (Web Server), in our case JBoss, we had to modify

run.sh
and add the java.library.path as a VM argument there.

Something like this:

JBOSS_NATIVE_DIR="$JBOSS_NATIVE_DIR:/usr/lib/ure/lib/"
JAVA_OPTS="$JAVA_OPTS -Djava.library.path=$JBOSS_NATIVE_DIR"

Thus, it is not correct to pass in VM arguments in ant.

Shervin