DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=16562>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=16562 Can not accept characters from keyboard in a thread under ant java task Summary: Can not accept characters from keyboard in a thread under ant java task Product: Ant Version: 1.5.1 Platform: PC OS/Version: Windows XP Status: NEW Severity: Blocker Priority: Other Component: Core tasks AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] I have two classes one of them runs thread which is accepting data from keyboard. Everything is going fine if I run my program in cmd window (Windows XP) like “c:\> java A “, where A is name of class with main method. I can accept symbols from keyboard in my thread. As soon as I run same program using ant, there is no respond from my program. It seems to me either there is something I need to add to "java" task as a parameter or something is wrong with ant. I also tried to run batch file from ant environment, but it did not help me. Below you can find my test classes both batch file as well as build file. Sinserely, Aleksandr Grinberg [EMAIL PROTECTED] /////////////////////////////////////////////////////////////////////// // class with main method import java.io.*; class A{ public static void main(String[] args) { String f="1234 "; String x=" "; String empty=""; System.out.println (" emty string " + empty.trim().length()); System.out.println ("f.indexof(x) " +f.indexOf(x) ); System.out.println(" f.substring(f.indexof(x) " + f.substring(f.indexOf (x))); System.out.println(" f.substring(f.indexof(x).length() " + f.substring(f.indexOf(x)).length() ); Console console = new Console(); console.start(); } } /////////////////////////////////////////////////////////////////////// // thread class that interacts with console import java.lang.Thread; import java.io.*; public class Console extends Thread { public void run() { byte b[] = new byte[200]; int bites_in_buffer = 0; BufferedReader is = new BufferedReader (new InputStreamReader (System.in)); int bytes_read = -1; while ( true ) { try{ String command = is.readLine(); if (command.length() == 0) break; // execute command // inform user about executing System.out.println ("Executing command......"); // delay try{ sleep (1000); } catch (InterruptedException e) {} // print results System.out.println ("Entered command : " + command); } catch (Exception e) { System.out.println (e); } } System.out.println ("leaving thread "); } public void die() { } } /////////////////////////////////////////////////////////////////////// // build.xml file <project name="TEST" default="init" basedir="."> <description> build file </description> <!-- set global properties for this build --> <target name="compile"> <javac srcdir="${basedir}" > </javac> </target> <target name="run-thread" depends="compile"> <java classname="A" fork="true" > <classpath path="${basedir}"/> </java> </target> <target name="run-bat" depends="compile"> <exec executable="run-thread.bat"> </exec> </target> </project> /////////////////////////////////////////////////////////////////////// //this is a body of run-thread.bat file java A /////////////////////////////////////////////////////////////////////// // --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]