You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by ar <ar...@free.fr> on 2006/02/23 14:54:17 UTC

List of file names as arguments to a java task

Hi all,

I'd like to give to provide to my java task a list of file names. I don't
know how to do.
I tried:

        <java classname="my.company.my.class.MyClass">
           <classpath>
              <fileset dir="${lib.dir}">
                 <include name="**/*.jar"/>
              </fileset>
           </classpath>
           <arg line="--myoption=value" />
           <fileset dir="${work.dir}/xml">
              <include name="**/*.xml"/>
           </fileset>
        </java>
... but it doesn't work.

The java command I want to get is :

java -cp my_classpath my.company.my.class.MyClass --myoption=value
file1.xml file2.xml file3.xml file4.xml

Any idea ?

Regards
-- 
A. ROY

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: List of file names as arguments to a java task

Posted by Kjersti Berg <kj...@gmail.com>.
>
> So my problem is to
> get a space delimited list of file names and to add it to the list of
> arguments to my java command.


I had a case where I needed to run a Java program on a set of files. I used
the apply task for that, but I don't know if this matches your requirements
exactly. As far as I understood it, this will execute the a command once for
each file in the fileset. It doesnt appear that the java task takes a
fileset as an argument.

Subsidiary question :
> Is there a limit to the length of the string given as argument to a java
> command ?


Not in Java per se I think, but Windows has a limit on how long a command
line can be.
See this for ex: http://gcc.gnu.org/ml/gcc-help/2005-11/msg00254.html

Kjersti

Re: List of file names as arguments to a java task

Posted by ar <ar...@free.fr>.
Le Thu, 23 Feb 2006 15:20:46 +0100, Mark Russell  
<ma...@instantiations.com> a écrit:

> You are telling the compile command to only include the **/*.xml files
> it probably should be **/*.java

No. It's well **/*.xml I want to give as argument. I don't use the "javac"  
task (compile task) but the "java" task (execution of a java class  
accepting a list of file names as input parameter). So my problem is to  
get a space delimited list of file names and to add it to the list of  
arguments to my java command.

Subsidiary question :
Is there a limit to the length of the string given as argument to a java  
command ?

Thanks for your answers

A. ROY

> ar wrote:
>> Hi all,
>>
>> I'd like to give to provide to my java task a list of file names. I  
>> don't
>> know how to do.
>> I tried:
>>
>>        <java classname="my.company.my.class.MyClass">
>>           <classpath>
>>              <fileset dir="${lib.dir}">
>>                 <include name="**/*.jar"/>
>>              </fileset>
>>           </classpath>
>>           <arg line="--myoption=value" />
>>           <fileset dir="${work.dir}/xml">
>>              <include name="**/*.xml"/>
>>           </fileset>
>>        </java>
>> ... but it doesn't work.
>>
>> The java command I want to get is :
>>
>> java -cp my_classpath my.company.my.class.MyClass --myoption=value
>> file1.xml file2.xml file3.xml file4.xml
>>
>> Any idea ?
>>
>> Regards
>> --A. ROY
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>> For additional commands, e-mail: user-help@ant.apache.org
>>
>>
>
>



-- 
A. ROY

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: List of file names as arguments to a java task

Posted by Mark Russell <ma...@instantiations.com>.
You are telling the compile command to only include the **/*.xml files
it probably should be **/*.java
ar wrote:
> Hi all,
> 
> I'd like to give to provide to my java task a list of file names. I don't
> know how to do.
> I tried:
> 
>        <java classname="my.company.my.class.MyClass">
>           <classpath>
>              <fileset dir="${lib.dir}">
>                 <include name="**/*.jar"/>
>              </fileset>
>           </classpath>
>           <arg line="--myoption=value" />
>           <fileset dir="${work.dir}/xml">
>              <include name="**/*.xml"/>
>           </fileset>
>        </java>
> ... but it doesn't work.
> 
> The java command I want to get is :
> 
> java -cp my_classpath my.company.my.class.MyClass --myoption=value
> file1.xml file2.xml file3.xml file4.xml
> 
> Any idea ?
> 
> Regards
> --A. ROY
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 
> 


-- 
Mark Russell
Instantiations, Inc.
724-368-3331 (land line)
http://www.instantiations.com


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org