Hello I am trying to issue gcloud command within a java app using process builder.
public static void sendCmd() {
ProcessBuilder processBuilder = new ProcessBuilder();
processBuilder.command("cmd.exe", "/c", "gcloud");//"");
try {
Process process = processBuilder.start();
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line;
while ((line = reader.readLine()) != null) {
System.out.println(line);
}
int exitCode = process.waitFor();
System.out.println("\nExited with error code : " + exitCode);
} catch (Exception e) {
e.printStackTrace();
}
}
The result:
Exited with error code : 1 Process finished with exit code 0
If I type 'gcloud' into command prompt I receive the full help message - as expected.
gcloud not recognized as an internal or external command on Windows gcloud not recognized as an internal or external command on Windows
I've looked through multiple threads - my PATH is set correct 'C:\Users\Home\AppData\Local\Google\Cloud SDK\google-cloud-sdk\bin'
and I've added ';.PY' to PATHEXT.
gcloud works fine in cmd prompt but cant access it programmatically?