You may execute external commands using Runtime as shown below.

Java Code:
try {
String line;
Process p = Runtime.getRuntime().exec
(System.getenv("windir") +"\\system32\\"+"tree.com /A");
BufferedReader input = new BufferedReader
(new InputStreamReader(p.getInputStream()));
while ((line = input.readLine()) != null) {
        System.out.println(line);
}
 input.close();
}
catch (Exception err) {
      err.printStackTrace();
}