Results 1 to 5 of 5

Thread: cmd command

  1. #1
    jperson is offline Member
    Join Date
    Jan 2010
    Posts
    61
    Rep Power
    0

    Default cmd command

    i want to excute cmd command using java
    i use Runtime.getRuntime().exec("command"), but i want to open cmd window and see the result of this command on cmd window

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,571
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by jperson View Post
    i want to excute cmd command using java
    i use Runtime.getRuntime().exec("command"), but i want to open cmd window and see the result of this command on cmd window
    You can get the output stream from the process (read the API documentation for the Process class) and do with the ouput whatever you want. A JTextArea comes to mind.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    jperson is offline Member
    Join Date
    Jan 2010
    Posts
    61
    Rep Power
    0

    Default

    thank you JosAH for your reply , but i can open cmd with my command or not ?

  4. #4
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,571
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by jperson View Post
    thank you JosAH for your reply , but i can open cmd with my command or not ?
    If I understood you right, yes, you can. Cmd.exe is MS Windows' shell program and if you want to use it interactively you also need/want to use the InputStream from the Process class.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  5. #5
    JavaHater is offline Senior Member
    Join Date
    Dec 2010
    Posts
    165
    Rep Power
    4

    Default

    Quote Originally Posted by jperson View Post
    i want to excute cmd command using java
    i use Runtime.getRuntime().exec("command"), but i want to open cmd window and see the result of this command on cmd window
    you can try putting a pause, eg Runtime.getRuntime().exec("command && pause").
    note: I did not try this, so you have try yourself.

Similar Threads

  1. help me!!!! about command prompt..
    By kureikougaiji in forum New To Java
    Replies: 2
    Last Post: 11-13-2008, 06:15 PM
  2. Does the JRE come with command to run?
    By gotenks05 in forum New To Java
    Replies: 5
    Last Post: 10-25-2008, 12:00 AM
  3. command
    By dirtycash in forum New To Java
    Replies: 8
    Last Post: 01-02-2008, 07:52 PM
  4. command help
    By dirtycash in forum New To Java
    Replies: 1
    Last Post: 12-05-2007, 12:24 AM
  5. Unable to execute command line command in java
    By LordSM in forum New To Java
    Replies: 1
    Last Post: 08-08-2007, 12:23 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •