Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run application (non java) out of Java Based menu

Status
Not open for further replies.

josel

Programmer
Oct 16, 2001
716
US
Howdy!

I am very interested in learning Java. I bought Jbuilder to help alone and have managed to build a small menu application :) This is a big leap for me!

I write, support and maintain database application in UNIX and WINDOWS. A sample command for this application will read: rclerk afile -s1 -lx -h "Title"

QUESTION:
How can I have above command execute from within my java menu?

Thank you all in advance!


Jose Lerebours




KNOWLEDGE: Something you can give away endlessly and gain more of it in the process! - Jose Lerebours
 
You can use "jva.lang.Runtime".
The following code will launch notepad on a Windows system.
Code:
package com.ecc.swing2;

public class WinCmdExample {

  public WinCmdExample() {
  }

  private void doIt() {
    Runtime run = Runtime.getRuntime();
    String[] args = { "COMMAND.COM", "/C", "notepad" };
    try {
      run.exec(args);
    } catch (java.io.IOException e) {
    }
  }

  public static void main(String[] args) {
    WinCmdExample example = new WinCmdExample();
    example.doIt();
  }
}
 
hologram,

Oh man, how I wish I *clearly* understood the code, as simple as it might be.

I will give this a try - I guess all I have to do is cut and paste within action for my menu option

thanks so very much!


Jose Lerebours

KNOWLEDGE: Something you can give away endlessly and gain more of it in the process! - Jose Lerebours
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top