package src;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Command
{
public static void main(String args[])
{
try
{
Process p=Runtime.getRuntime().exec("cmd /c dir");
p.waitFor();
BufferedReader reader=new BufferedReader(new InputStreamReader(p.getInputStream()));
String line=reader.readLine();
while(line!=null)
{
System.out.println(line);
line=reader.readLine();
}
}
catch(IOException e1) {}
catch(InterruptedException e2) {}
System.out.println("Done");
}
}
I tried to run this code but it is not able to execute anything. Are there some classpath or other settings i need to do to make this work?