I am trying to run cmd commands through java. Commands like 'explorer', 'notepad' are running, but commands like 'dir' 'path' are not working it is throwing exception, output says:-
Problem in Executing Command java.io.IOException: Cannot run program "path": CreateProcess error=2, The system cannot find the file specified
boolean exc(String command){
Process p;String pingResult="";
try{
p=Runtime.getRuntime().exec(command);
BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null) {
System.out.println(inputLine);
pingResult += inputLine;
}
in.close();
return true;
}catch(Exception e){
System.out.println("Problem in Executing Command "+e.toString());
return false;
}
}
see, if any problem in my code.