Forum Stats

  • 3,760,228 Users
  • 2,251,665 Discussions
  • 7,871,030 Comments

Discussions

exec a command

843798
843798 Member Posts: 24,864
edited Jun 20, 2001 12:09PM in Java Runtime Environment (JRE)
hi,
i am not to familiar with runtime controls so please help. I am trying to have a command executed from the prompt. I want the user to be able to view an excel sheet upon clicking a button on the application window.
How can i do that? do i need to import libraries? extend anything or throw anything? Also
should i use: Runtime.exec("command"); because it didnt work.
Thanks
Rick

Comments

  • 843798
    843798 Member Posts: 24,864
    Hello,

    here are some litte hints! ;-)



    String[] c = {"start " + f.getAbsoluteFile()};
    // start the file (this works with mswin; under unix a //script with the name "start" is needed for this to //work
    try
    {
    Runtime.getRuntime().exec(c);
    }
    catch ( Exception x )
    // we are running nt or 2000 and start it as an internal command!
    {
    String[] n = {"cmd.exe", "/C", "\"" + f.getAbsoluteFile().toString() + "\"" };
    Runtime.getRuntime().exec(n);
    }

    regards,

    Hendrik

    ----------------------------------------
    [email protected], http://www.netmedia.de

    netmedia GmbH
    Neugrabenweg 5-7
    66123 Saarbruecken
    Germany

    fon: +49 (0) 681 / 3 79 88 - 0
    fax: +49 (0) 681 / 3 79 88 - 99
This discussion has been closed.