There are a few problems here.
- the
*.java part is a glob that is usually expanded by the shell
- assembling a pipeline from process to process is also a shell feature
- the output redirection is a shell feature
Basically, you really need to invoke a shell to run this type of pipeline. The exec method runs a specific program with arguments. You might be able to get this to work by invoking the shell directly and passing the command line as an argument but I doubt that would work either.
You may have to implement the cat *.java part by enumerating the directory contents and reading each file separately. The open separate Process instances for each of the sed commands and implement the pipeline between them using the input and output streams of the Process instances.