Executing external program in Java-Collection of common programming errors
Make either an script for bash:
"/bin/bash" "-c" "cut file.txt -d' ' -f1-2 > hits.txt"
or split
"cut" "file.txt" "-d" "' '" "-f" "1-2"
The error message clearly says:
Cannot run program "cut file.txt"
so it interprets “cut file.txt” as a single programname with a blank inside.
Your problem starts with the redirection, because you can’t redirect the output that way:
"cut" "file.txt" "-d" "' '" "-f" "1-2" ">" "hits.txt"
You have to handle input and output streams. It might be a better idea to implement cut in Java, to get a portable solution, or call a script which the user may specify on commandline or in a config file, so that it can be adapted for Windows or other platforms.
Calling /bin/bash and redirecting there should work – on unix like systems.