Java – Netbeans 6.5: Change an environment variable during run/debug/test

antjavanetbeans

Up until Netbeans 6.1, I was using the following recipe to change the PATH environment variable during run/debug/test tasks: in the build.xml file I included:

<property environment="env"/>
<target name="-init-macrodef-java">
   <macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1">
       <attribute default="${main.class}" name="classname"/>
       <element name="customize" optional="true"/>
       <sequential>
           <java classname="@{classname}" dir="${work.dir}" fork="true">
               <jvmarg line="${run.jvmargs}"/>
               <env key="Path" path="${work.dir}/../../bin;${env.Path}">                              
...

(this was for Windows machines). Under Netbeans 6.5, this magic no longer seems to work, not for PATH, or other environment variables (using key="…" value="…" instead). I rebuild the NB projects from scratch to little avail, and I am no Ant expert to begin with. Any pointers/suggestions?

Best Solution

Try using

 <env key="PATH" path="..."/>

instead of

 <env key="Path"  path="..."/>

it is case insensitive only on Windows and ant > 1.7