Results 1 to 8 of 8
Like Tree1Likes
  • 1 Post By Norm

Thread: Correct Command Format inside Runtime.getRuntime.exec(“ ”) block

  1. #1
    ashwinbb is offline Member
    Join Date
    Jun 2014
    Posts
    4
    Rep Power
    0

    Default Correct Command Format inside Runtime.getRuntime.exec(“ ”) block

    I want to execute a command in my java program using below function.

    Process p = Runtime.getRuntime().exec();

    My command om cmd prompt looks something like

    C:\Program Files\IBM\MQSI\9.0.0.0>mqsicacheadmin IB9NODE -c clearGrid -m myMapName

    Please do tell correct format of writing above command inside exec() block am getting some error when tried.

    Thanks in advance

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,003
    Rep Power
    33

    Default Re: Correct Command Format inside Runtime.getRuntime.exec(“ ”) block

    am getting some error when tried.
    Please copy the full text of the error message and paste it here.

    Can you post the code that is being used that shows the problem?
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    ashwinbb is offline Member
    Join Date
    Jun 2014
    Posts
    4
    Rep Power
    0

    Default Re: Correct Command Format inside Runtime.getRuntime.exec(“ ”) block

    Error says it could not locate since the format i had written above command is not correct

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,003
    Rep Power
    33

    Default Re: Correct Command Format inside Runtime.getRuntime.exec(“ ”) block

    Please copy the full text of the error message and paste it here. It has important info about the error.

    Also post the code that is causing the error.
    If you don't understand my response, don't ignore it, ask a question.

  5. #5
    ashwinbb is offline Member
    Join Date
    Jun 2014
    Posts
    4
    Rep Power
    0

    Default Re: Correct Command Format inside Runtime.getRuntime.exec(“ ”) block

    Well forget about the error..,
    my only doubt is how to specify my command

    "mqsicacheadmin IB9NODE -c clearGrid -m myMapName"

    on command prompt its look like
    C:\Program Files\IBM\MQSI\9.0.0.0>mqsicacheadmin IB9NODE -c clearGrid -m myMapName


    how do i specify it as a string inside getRuntime.exec("here");

    the format is what i need

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,003
    Rep Power
    33

    Default Re: Correct Command Format inside Runtime.getRuntime.exec(“ ”) block

    how to specify my command

    "mqsicacheadmin IB9NODE -c clearGrid -m myMapName"
    What have you tried? What happens when you replace "here" with the command line you show?
    Last edited by Norm; 06-19-2014 at 12:00 AM.
    If you don't understand my response, don't ignore it, ask a question.

  7. #7
    ashwinbb is offline Member
    Join Date
    Jun 2014
    Posts
    4
    Rep Power
    0

    Default Re: Correct Command Format inside Runtime.getRuntime.exec(“ ”) block

    i gave
    Process p = Runtime.getRuntime().exec("C:/Program Files/IBM/MQSI/9.0.0.0>mqsicacheadmin IB9NODE -c clearGrid -m myMapName");

    i says it could'nt file...am executing a command after all..i know am going wrong in specifying Command string in exec...jus wanted to know correct one

  8. #8
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,003
    Rep Power
    33

    Default Re: Correct Command Format inside Runtime.getRuntime.exec(“ ”) block

    What directory do you want the command to have as its current directory when it executes? Can it be where the exe file is located?
    See the API doc for the Runtime class for different exec() methods that give you other options.

    That is not a valid path to a file:
    "C:/Program Files/IBM/MQSI/9.0.0.0>mqsicacheadmin
    The path to the exe file could be something like this:
    "C:/Program Files/IBM/MQSI/9.0.0.0/mqsicacheadmin.exe
    Last edited by Norm; 06-19-2014 at 12:25 AM.
    gimbal2 likes this.
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. Is there an alternative to Runtime.getRuntime().exec()
    By md_suzon in forum Advanced Java
    Replies: 5
    Last Post: 04-24-2013, 03:17 PM
  2. Runtime.getRuntime().exec() and pppd
    By mysticav in forum Networking
    Replies: 7
    Last Post: 02-15-2011, 08:44 PM
  3. Replies: 5
    Last Post: 07-07-2010, 01:50 PM
  4. help with Runtime.getRuntime().exec
    By collin389 in forum AWT / Swing
    Replies: 3
    Last Post: 11-09-2009, 05:22 AM
  5. Replies: 6
    Last Post: 12-29-2008, 03:47 PM

Posting Permissions

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