I have a code which takes some adb commands and reads the input to be later reflected in JTextField. It works fine in windows but in linux, the same code gives a host of errors such as IOexception(No such file or directory). Do we have to specify OS specific environment setup in this case
ProcessBuilder process5 = new ProcessBuilder("adb", "shell","getprop","ro.product.model");
Process p1 = process5.start();
InputStream stdin1 = p1.getInputStream();
BufferedReader writer1 = new BufferedReader(new InputStreamReader(stdin1));
String model=writer1.readLine();
Error mgs-
Exception in thread "main" java.io.IOException: Cannot run program "adb": error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
at pb.main(pb.java:24)
Caused by: java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(UNIXProcess.java:248)
at java.lang.ProcessImpl.start(ProcessImpl.java:134)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
... 1 more
Can you invoke adb with absolute path? You can find absolute path with whereis adb
. You can also check what echo $PATH
from JAVA process builder returns in order to get same path as Java program.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.