代码如下:
ProcessBuilder processBuilder1 = new ProcessBuilder("/usr/bin/which", "adb");
Process process = null;
try {
process = processBuilder1.start();
} catch (IOException e) {
e.printStackTrace();
}
inputStreamThread inputTread = new inputStreamThread(process);
inputTread.run();
try {
process.waitFor();
} catch (InterruptedException e) {
e.printStackTrace();
}
process.destroy();
ADB = inputTread.inputStreamOutput.substring(0,inputTread.inputStreamOutput.length()-1);
如果我用java -jar xxxx.jar
运行它,则可以得到真实的结果,但是如果我双击jar文件,ADB结果为空,则我尝试使用新的ProcessBuilder("which", "adb");
,但是没有用。