pro*_*spk 2 java notifications ubuntu-10.04
我试图通过java访问Ubuntu中的通知气泡
这是我的代码
class TestOSD{
public static void main(String[] args) throws Exception{
String[] cmmd = {"/usr/bin/notify-send -t 10000 \"Hello OSD\" \"This is my first programmatic OSD notification\""};
System.out.println("This is said : Hello OSD");
Runtime.getRuntime().exec(cmmd);
}
}
Run Code Online (Sandbox Code Playgroud)
我在命令行中获取此堆栈跟踪
Exception in thread "main" java.io.IOException: Cannot run program "/usr/bin/notify-send -t 10000 "Hello OSD" "This is my first programmatic OSD notification"": java.io.IOException: error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:460)
at java.lang.Runtime.exec(Runtime.java:593)
at java.lang.Runtime.exec(Runtime.java:466)
at TestOSD.main(TestOSD.java:6)
Caused by: java.io.IOException: java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.<init>(UNIXProcess.java:148)
at java.lang.ProcessImpl.start(ProcessImpl.java:65)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:453)
... 3 more
Run Code Online (Sandbox Code Playgroud)
基本上我无法理解exec()Runtime类的方法的重载?有人可以在这方面帮助我吗?
Jon*_*eet 12
我相信问题在于它正在寻找整个字符串作为启动过程的名称.试试这个:
String[] cmd = { "/usr/bin/notify-send",
"-t",
"10000",
"Hello OSD This is my first programmatic OSD notification"};
Run Code Online (Sandbox Code Playgroud)
这应该从参数中分离出进程的名称,并从其余参数中分离出每个参数.
| 归档时间: |
|
| 查看次数: |
1360 次 |
| 最近记录: |