I want to list all the file and write the list to a .txt file by using Runtime from Java. And I did this :

File workDir = new File("/home/name/ghost/");
String cmd = "ls -l > data.txt";
Process pr = Runtime.getRuntime().exec(cmd, null , workDir);

it didn't work until I replace the cmd command by a shellscript:
String cmd = "./shell.sh";
and here is what in the shell script :
#!/bin/bash
ls -l > data.txt
exit 0

I want to ask why I can't access system command directly through Java ?