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 6079001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:53:49+00:00 2026-05-23T10:53:49+00:00

Is there a way to mask the password when using the <input …/> task

  • 0

Is there a way to mask the password when using the <input .../> task in ANT from the Eclipse IDE?

I see a way to do it from the command line:

<input message="secure-input:" addproperty="the.password">
    <handler classname="org.apache.tools.ant.input.SecureInputHandler" />
</input>

But this doesn’t work in eclipse.

  • 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-23T10:53:50+00:00Added an answer on May 23, 2026 at 10:53 am

    EDIT : As ant secure Input handler still doesn’t work in eclipse 4.x, here’s a solution based on ant script task, working with builtin javascript engine (since JDK 1.6.0_06), so no extra libraries needed :

    <project>
    <script language="javascript">
     // imports
     importClass(javax.swing.JPasswordField);
     importClass(javax.swing.JOptionPane);
    
     var pw = new JPasswordField();
     var choice = JOptionPane.showConfirmDialog(null, pw, "Enter Password..", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
    
     if (choice == JOptionPane.OK_OPTION) {
      // create ant property
      project.setNewProperty("pwd", pw.getText());
     } else {
      throw "Password required !!";
     }
    </script>
    
    <echo>$${pwd} => ${pwd}</echo>
    </project>
    

    The method JPasswordField.getText() is deprecated,
    normally you would use getPassword(), but it doesn’t work.

    // create ant property
    var s = new String(pw.getPassword());
    project.setNewProperty("pwd", s);
    

    takes only the chararray, whereas :

    // create ant property
    var s = String.valueOf(pw.getPassword());
    project.setNewProperty("pwd", s);
    

    results in :

    [echo] ${pwd} => function String() { [native code for String.String, arity=1] }
    

    maybe a bug in the javascript engine !? (using jdk 1.7.0_60)

    Since version 1.7.1 Ant has support for Java 1.6’s secure console input feature, see Ant Manual. What version of Eclipse and Java do you use ? Alternatively you may use :
    AntForms which has a lot of input dialogs and support for passwords too
    or
    Jera Ant Tasks which has a query task with optional password masking

    EDIT : adding a specific example using groovy..

    You may use a scripting language to open a dialog, here is an example using Groovy =

    <project>
    <taskdef name="groovy" classname="org.codehaus.groovy.ant.Groovy"/>
    
     <groovy>
     import groovy.swing.SwingBuilder
     import javax.swing.JFrame
    
     boolean isAlive = true
     swing = new SwingBuilder()
     button = swing.button('OK')
     frame = swing.frame(title:'Password', defaultCloseOperation:JFrame.EXIT_ON_CLOSE) {
       panel {
         pw = passwordField(columns:10)
         widget(button)
       }
     }
     button.actionPerformed = {
       // set Ant property for further processing
       properties.'password' = pw.text
       isAlive = false
     }
     frame.pack()
     frame.show()
    
     // prevent ant from closing the window
     while(isAlive) {
      sleep(1000)
     }
    </groovy>
    
    <echo>$${password} = ${password}</echo>
    
    </project>
    

    Finally write your own Inputhandler, see http://sourceforge.net/projects/emaria/files/antdocs/antinput/antinput.pdf/download for details

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

Sidebar

Related Questions

Is there a way to set Ajax MaskedEditExtender Mask by jquery secript. I'm using
Is there a way to mask my real server technology say from PHP to
Is there a way to manipulate alpha of an image using alpha from another
Is there a way to set an input mask in MS Access 2007 so
Using meioMask Plugin is there any way to set up a mask so it
Using meioMAsk plugin is there any way to set up a mask so it
Is there any way to change the ownership and permission mask for a semaphore
is there way how to get name ov event from Lambda expression like with
Is there any way to check whether a file is locked without using a
Possible Duplicate: Ignore SVN files when exporting a WAR file from Eclipse? Using eclipse

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.