Ok, I´ve done some tests...

App.java just print the given arguments.
The buildfile compiles that and uses several different invocations for that
application with a "path" as "argument"

Maybe we dont know exactly what you want to achieve, but I´m sure you get
your solution here ;-)


Jan



App.java
---8-<-------8-<-------8-<-------8-<-------8-<-------8-<-------8-<-------8-<----
public class App {
    public static void main(String[] args) {
        System.out.println("args (" + args.length + ")");
        for (int i=0; i<args.length; i++) {
            System.out.println("  " + i + ": " + args[i]);
        }
    }
}
---8-<-------8-<-------8-<-------8-<-------8-<-------8-<-------8-<-------8-<----




Directory Layout
---8-<-------8-<-------8-<-------8-<-------8-<-------8-<-------8-<-------8-<----
C:.
|   App.class
|   App.java
|   build.xml
|
\---files
        with a space.file
        withoutaspace.file
---8-<-------8-<-------8-<-------8-<-------8-<-------8-<-------8-<-------8-<----


build.xml
---8-<-------8-<-------8-<-------8-<-------8-<-------8-<-------8-<-------8-<----
<project>

    <javac srcdir="." destdir="."/>


    <path id="p">
        <pathelement location="files/with a space.file"/>
        <pathelement location="files/withoutaspace.file"/>
    </path>



    <!-- all elements in ONE string
    args (1)
      0: C:\tmp\ant-javaWithPath\files\with a 
space.file;C:\tmp\ant-javaWithPath\files\withoutaspace.file
    -->
    <java classname="App" classpath=".">
        <arg pathref="p"/>
    </java>    


    <!-- all in ONE string and then split on spaces
    args (3)
      0: C:\tmp\ant-javaWithPath\files\with
      1: a
      2: space.file;C:\tmp\ant-javaWithPath\files\withoutaspace.file
    -->
    <property name="p2" refid="p"/>
    <java classname="App" classpath=".">
        <arg line="${p2}"/>
    </java>    


    <!-- each path element in its own variable; on several threads 
    args (1)
      0: C:\tmp\ant-javaWithPath\files\with a space.file
    args (1)
      0: C:\tmp\ant-javaWithPath\files\withoutaspace.file
    -->
    <apply executable="java">
        <arg line="-classpath ."/>
        <arg value="App"/>
        <path refid="p"/>
    </apply>


    <!-- each path element in its own variable; in one application 
    args (2)
      0: C:\tmp\ant-javaWithPath\files\with a space.file
      1: C:\tmp\ant-javaWithPath\files\withoutaspace.file
    -->
    <pathconvert property="p3" refid="p"
        pathsep="&quot; &quot;"
    />
    <property name="p4" value="&quot;${p3}&quot;"/> 
    <java classname="App" classpath=".">
        <arg line="${p4}"/>
    </java>    


</project>
---8-<-------8-<-------8-<-------8-<-------8-<-------8-<-------8-<-------8-<----

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to