Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Using a message box to display errors

807600Jul 19 2007 — edited Jul 23 2007
I have a program that uses Swing componants to make various system calls. I am wanting to display (or trap) any errors that occur while running the command and display the error(s) in a single message box.

Here is a sample of the code for one of my system calls...
private void btn_CreatereplicaActionPerformed(java.awt.event.ActionEvent evt) {                                                  
// TODO add your handling code here:
     String Work = txt_Workdir.getText();
     String Export = txt_Exportdir.getText();
     String Host = txt_Hostname.getText();
     String command = ("cmd /c multitool mkreplica -export -workdir " + Work + " -nc -out " + Export + " hostname:" + Host);
     
     Process p = null;
        try {
            p = Runtime.getRuntime().exec(command);
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }                
Curretly if the user does something wrong when running the "command" the program just sits there (unlike a cmd prompt that displays the error). How do I get an error (if any) to pop up in a message box?

Thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 20 2007
Added on Jul 19 2007
7 comments
153 views