Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 441609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T20:59:22+00:00 2026-05-12T20:59:22+00:00

My command line app call looks like this: java -jar myapp.jar –output c:\test.txt c:\test.txt

  • 0

My command line app call looks like this:

java -jar myapp.jar --output c:\test.txt c:\test.txt

Which reads test.txt, processes it and saves result to the same file.

I am trying to make ant task out of it but can’t figure out how to make it use same path for input and output.

    <target name="compress">
        <apply executable="java" parallel="false">
            <fileset dir="c:/test/" includes="*.txt">
            </fileset>
            <arg line="-jar"/>
            <arg path="myapp.jar"/>
            <srcfile/>
            <arg line="--output"/>
            <mapper type="glob" from="*" to="c:/test/*"/>
            <targetfile/>
        </apply>
    </target>

Which doesn’t work. Using <mapper type="identity"/> and setting dest="c:/test/" for apply task doesn’t work either. Looks like it just doesn’t want to rewrite existing files. Is there a way to make it work without writing output to a separated folder, then deleting all files from the original folder and copying files back to original folder?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T20:59:23+00:00Added an answer on May 12, 2026 at 8:59 pm

    First of, you should be using <arg value="..."/> rather than <arg line="..."/>. The latter is not going to work for multiple arguments and should be avoided in general.

    Secondly, apply task compares target files with source files and will not be invoked if both are the same (or if the target file is newer than source which is obviously not applicable in your case). You can use force="true" attribute to avoid this.

    The following works for me:

    <target name="compress">
      <apply executable="java" parallel="false" dest="c:/test/" force="true">
        <fileset dir="c:/test/" includes="*.txt" />
        <arg value="-jar"/>
        <arg path="myapp.jar"/>
        <srcfile/>
        <arg value="--output"/>
        <mapper type="identity"/>
        <targetfile/>
      </apply>
    </target>
    

    You can run Ant in verbose mode (using “-v” switch) to see the actual command lines this task is generating.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Background In a C# command-line app I'm writing, several of the parameters have yes
I have a command line app the continuously outputs YAML data in the form:
I have a command line Ruby app I'm developing and I want to allow
I have an existing app with a command-line interface that I'm adding a GUI
Is it possible to add custom command-line arguments to an Eclipse .app folder? In
I need to create a command line look-and-feel in a WPF app. In WPF,
Via command line, I usually do this: cp -rRp /path/to/a\_folder/. /path/to/another\_folder This copies just
The (command line) interface I have in mind is like so: watching FILE+ do
What command line util can i use to create a thumbnail preview of a
I am redesigning a command line application and am looking for a way to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.