Here is the code:
String cmd = "/usr/local/postgresql/bin/postgres -D /usr/local/postgresql/data >logfile 2>&1 &";
Process p = Runtime.getRuntime().exec(cmd);
It doesn't work. The command is supposed to start the postgres server, but I checked that the server didn't start which means the command wasn't executed. But it worked if the command is like this: /usr/local/postgresql/bin/postgres -D /usr/local/postgresql/data
which just start the server but no need to write to logfile.
So I guess the characters in the command maybe a problem. And I tried this solution. It still didn't work though. Then I realized maybe it's the permission issue? I mean the java file doesn't have the permission to write to the logfile? But I don't know how to solve this one. Any suggestion? Thanks in advance.