When I use the following java to run the same command, which does not ask me any input. Maybe bash and java launch another process differently.
-------------------------------------
String command = "/usr/bin/psql postgresql://" +userName + ":" + password +"@"+ host + ":" + port + "/xbrlam -f /tmp/xbrlPublicPostgresDB.ddl";
try {
Process process = Runtime.getRuntime().exec(command);
StreamGobbler streamGobbler = new StreamGobbler(process.getInputStream(), System.out::println);
Executors.newSingleThreadExecutor().submit(streamGobbler);
int exitValue = process.waitFor();
if (exitValue == 0) {
System.out.println("XBRL-US db is ready.");
} else {
throw new RuntimeException("XBRL-US db wrong");
}
} catch (Exception e) {
throw new RuntimeException(e);
}