I am trying to access the notification bubble in Ubuntu through java
here is my code
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);
}
}
I am getting this stacktrace in my command line
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
Basically i can't understand the overloads of exec() method of the Runtime class? Can anybody help me out in this regard?
I believe the problem is that it's looking for the whole string as the name of the process to start. Try this instead:
String[] cmd = { "/usr/bin/notify-send",
"-t",
"10000",
"Hello OSD This is my first programmatic OSD notification"};
That should separate out the name of the process from the arguments, and each argument from the rest.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With