मैं जावा कोड से एक बाहरी कमांड निष्पादित करने की कोशिश कर रहा हूं, लेकिन एक अंतर है जिसे मैंने Runtime.getRuntime().exec(...)और के बीच देखा है new ProcessBuilder(...).start()।
उपयोग करते समय Runtime:
Process p = Runtime.getRuntime().exec(installation_path +
uninstall_path +
uninstall_command +
uninstall_arguments);
p.waitFor();
बाहर निकलेंवैल्यू 0 है और कमांड ठीक है।
हालाँकि, इसके साथ ProcessBuilder:
Process p = (new ProcessBuilder(installation_path +
uninstall_path +
uninstall_command,
uninstall_arguments)).start();
p.waitFor();
निकास मान 1001 है और कमांड बीच में समाप्त हो जाती है, हालांकि waitForरिटर्न।
मुझे समस्या को ठीक करने के लिए क्या करना चाहिए ProcessBuilder?