Can't run program with ProcessBuilder, runs fine from command line

为君一笑 提交于 2019-12-02 05:31:38

Looks like the wildcard character is not being expanded using a glob. You can use a shell instead:

ProcessBuilder pb = 
       new ProcessBuilder("bash", "-c", "java -jar ~/myjar.jar \".*\"");

or you can remove the double-quotes around the wildcard:

ProcessBuilder pb = new ProcessBuilder(java, "-jar", "~/myjar.jar", ".*");

For. e.g. to get all the cpu frequency in Android.

ProcessBuilder p = new ProcessBuilder(); p.command("/system/bin/sh","-c","cat sys/devices/system/cpu/cpu*/cpufreq/scaling_cur_freq ");

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!