Runtime's exec() method is not redirecting the output
You need to use ProcessBuilder
to redirect.
ProcessBuilder builder = new ProcessBuilder("sh", "somescript.sh");
builder.redirectOutput(new File("out.txt"));
builder.redirectError(new File("out.txt"));
Process p = builder.start(); // may throw IOException
When you run a command, there is no shell running and any shell commands or functions are not available. To use something like &>
you need a shell. You have one but you are not passing it to it. try instead.
Runtime.getRuntime().exec(new String[] { "sh", "somescript.sh &> out.txt" });