I cannot find any answer to run a Linux command with header environment variable in JAVA.
The example command like this.
PGPASSWORD="mypassword" psql -h '12.34.56.78' -p '12345' -d 'testdb' -U 'testuser' -c "vacuum analyze dw.test"
I am not successful with Runtime.exec
, because it recognizes the first one as a command, but psql is the real command.
How can I run this command in JAVA, like shown below?
system("PGPASSWORD="mypassword" psql -h '12.34.56.78' -p '12345' -d 'testdb' -U 'testuser' -c "vacuum analyze dw.test"")