Want to add "PGPASSWORD" env variable from my java application.
I know using below way, we can add.
private void setPgPasswordEnv(String pwdValue) {
ProcessBuilder pb = new ProcessBuilder("CMD", "/C", "SET");
Map<String, String> envMap = pb.environment();
envMap.put("PGPASSWORD", pwdValue);
}
If we add using above, will it persist till my application runs?
Is there any best way to add env variable from java?