How to add system property equivalent to java -D in Ant

徘徊边缘 提交于 2019-12-04 01:22:06

Here is an example Ant target run that executes the example.jar and passes a system property with key="java.library.path" and value="/some/path":

<target name="run">
    <java jar="example.jar" fork="true">
        <jvmarg value="-Djava.library.path=/some/path"/>
    </java>
</target>

did you try to run

ant -Djava.library.path=/some/path ...  ?

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!