I am currently maintaining a non-GUI Java application which requires the ability to pop-up a system dialog at a specified target (server).
For Linux, I can pop-up this dialog using something similar to the following command:
Code:
xmessage -display <host>:0.0 <message>
where <host> is the server name, and <message> is the message to present to the operator.
For Windows XP, something similar to the following is used:
Code:
net send <host> <message>
Now, for Windows 7, from what I understand, "net send" is no longer supported. Thus I have been attempting to use the "msg" command; something like:
Code:
msg /server:<host> <user> <message>
where I merely set <user> to an asterisk (shift-8). The command above works as expected from a command prompt, however when I attempt to execute it from a Java application, it does not work. Here's the code I'm using:
Code:
import java.io.*;
public class Popup
{
public static void main(String[] args)
{
try
{
String[] app_args = { "msg", "*", "/server:localhost", "hello" };
Process p = Runtime.getRuntime().exec(app_args);
p.waitFor();
}
catch(IOException e1)
{
System.err.println(e1.toString());
}
catch(InterruptedException e2)
{
System.err.println(e2.toString());
}
}
}
This is the error I get:
Code:
java.io.IOException: Cannot run program "msg": CreateProcess error=2, The system cannot find the file specified
I've tried specifying the fully-qualified path to the command (C:\Windows\System32), however this does not work either. Can someone assist me with figuring this out? I do not have much experience with Windows.