start external program from Java

Discussion in 'Java' started by grz01@spray.se, Nov 7, 2005.

  1. Guest

    Java newbie question..

    In windows, if I want to start another application from Java-code,
    (like notepad.exe or invoke a document c:\mydoc.htm with my
    default-browser)
    what class/method do I use in Java?

    TIA,
    ------------------------------------------ grz01
     
    , Nov 7, 2005
    #1
    1. Advertising

  2. wrote:

    > Java newbie question..


    Note that a good group for those new to Java is ..
    <http://www.physci.org/codes/javafaq.jsp#cljh>

    > In windows, if I want to start another application from Java-code,
    > (like notepad.exe or invoke a document c:\mydoc.htm with my
    > default-browser)
    > what class/method do I use in Java?


    <http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Runtime.html#exec(java.lang.String)>
    [ ..and it's overloaded variants - scroll down. ]

    HTH
     
    Andrew Thompson, Nov 7, 2005
    #2
    1. Advertising

  3. chris_k Guest

    hi,
    you may use

    Process proc = Runtime.getRuntime().exec("notepad.exe");

    HTH,
    chris
     
    chris_k, Nov 7, 2005
    #3
  4. Roedy Green Guest

    On 7 Nov 2005 04:31:17 -0800, wrote, quoted or
    indirectly quoted someone who said :

    >In windows, if I want to start another application from Java-code,
    >(like notepad.exe or invoke a document c:\mydoc.htm with my
    >default-browser)
    >what class/method do I use in Java?


    see http://mindprod.com/jgloss/exec.html
    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Java custom programming, consulting and coaching.
     
    Roedy Green, Nov 7, 2005
    #4
  5. Rhino Guest

    <> wrote in message
    news:...
    >
    > Java newbie question..
    >
    > In windows, if I want to start another application from Java-code,
    > (like notepad.exe or invoke a document c:\mydoc.htm with my
    > default-browser)
    > what class/method do I use in Java?
    >
    > TIA,
    > ------------------------------------------ grz01
    >

    There is an excellent article on the techniques to use - and some pitfalls
    to avoid - in this article:
    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps_p.html

    The author begins by showing you basic approaches that may or may not work
    very well, then gradually improves them until he has arrived at fairly
    bulletproof ways of executing commands or external programs via Java.

    Rhino
     
    Rhino, Nov 7, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tobias Merler
    Replies:
    16
    Views:
    1,371
    Yakov
    Oct 3, 2004
  2. Scott Allen
    Replies:
    8
    Views:
    11,045
    Scott Allen
    May 2, 2004
  3. Bjorn
    Replies:
    2
    Views:
    847
    Jorgen Grahn
    Oct 12, 2009
  4. albert kao
    Replies:
    3
    Views:
    2,094
    Arne Vajhøj
    Feb 2, 2011
  5. Mellow Crow
    Replies:
    6
    Views:
    439
    Richard Cornford
    Nov 4, 2005
Loading...

Share This Page