public class Sonar {
public static void main(String[] args){
String sonarpath=System.getenv("Sonar");
sonarpath=sonarpath.replace("\\","\\\\");
String[] command={sonarpath+"\\StartSonar.bat"};
try {
Process p=Runtime.getRuntime().exec(command);
InputStreamReader in=new InputStreamReader(p.getInputStream());
int i=0;
while((i=in.read())!=-1){
System.out.print((char)i);
}
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
Trying to display the execution of sonar.bat file in eclipse console through this program. But it is not showing anything in the console and there are no errors also . I have searched on the web, but couldn't find anything useful It seems it is not entering into while loop, because i tried to print some string, it was not printing that also. I am not able to figure out the problem i have ran the .bat without opening the cmd before it is possible, and one of my bat is working fine in the console and i do not want to open a cmd