Ant java.library.path

Maybe this will save someone an hour... to set java.library.path from inside an ANT Java task, you need to set the parameter fork="true".

    <target name="run" depends="deploy">
       <java dir="${jlan}" classname="org.alfresco.jlan.app.JLANServer" fork="true">
         <arg value="${jlan}/jlanConfig.xml"/>
         <sysproperty key="java.library.path" path="${jlan}/jni"/>
         <classpath>
            <filelist dir="${jlan}">
                <file name="jars/alfresco-jlan.jar" />
                <file name="libs/cryptix-jce-provider.jar" />
                <file name="service/wrapper.jar" />
                <file name="libs/bullhorn-virtualfs-0.1.jar" />
                <file name="libs/log4j-1.2.14.jar" />
            </filelist>
         </classpath>
      </java>
    </target>

The reason seems to be that ANT does not allow you to reset a property. Once it's set, that's it. Of course, the ant task has its own java.library.path already, so manually setting it will be ignored. The fork is kind of a hack, by forcing a new process, you get clean system variables.



I'm currently working at NerdWallet, a startup in San Francisco trying to bring clarity to all of life's financial decisions. We're hiring like crazy. Hit me up on Twitter, I would love to talk.

Follow @chase_seibert on Twitter