Results 1 to 5 of 5

Thread: CMD Issue

  1. #1
    Gee's Avatar
    Gee
    Gee is offline Member
    Join Date
    Jan 2012
    Location
    England
    Posts
    3
    Rep Power
    0

    Default CMD Issue

    I want to create a batch file to:

    Launch a Executable Jar file (the program is ran in CMD, so I want the CMD to be open and run it, all by clicking the batch file) or to launch a .java, but I can change that myself.
    Then, I want the CMD to stay open, rather than closing.

    Any idea how I can do this?

    All the ways I've tried seem to just close as soon as they pop up, so when I launch it, the CMD just pops up & I see the program and it closes.
    I want to be able to keep the CMD up until I want to close it, not using the CMD function 'pause', as when I use this, upon pressing a key it closes.

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default Re: CMD Issue

    cmd has a /K option that starts a new instance of the command interpreter, carries out a specified command and then remains rather than terminates. You can see all of the options by typing the following at the command prompt:

    Java Code:
    cmd /?
    So you could try one or other of the following (note that it is a class that is launched not a .java file)

    Java Code:
    cmd /K java -cp . MainClass args here
    cmd /K java -jar app.jar args here

  3. #3
    Gee's Avatar
    Gee
    Gee is offline Member
    Join Date
    Jan 2012
    Location
    England
    Posts
    3
    Rep Power
    0

    Default Re: CMD Issue

    Quote Originally Posted by pbrockway2 View Post
    cmd has a /K option that starts a new instance of the command interpreter, carries out a specified command and then remains rather than terminates. You can see all of the options by typing the following at the command prompt:

    Java Code:
    cmd /?
    So you could try one or other of the following (note that it is a class that is launched not a .java file)

    Java Code:
    cmd /K java -cp . MainClass args here
    cmd /K java -jar app.jar args here
    "command cmd not recognised as internal or external command" blah blah blah :/

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,189
    Rep Power
    19

    Default Re: CMD Issue

    What's your OS?

    db

    edit To get better help sooner, post a SSCCE (Short, Self Contained, Compilable and Executable) example that demonstrates the problem.
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  5. #5
    Gee's Avatar
    Gee
    Gee is offline Member
    Join Date
    Jan 2012
    Location
    England
    Posts
    3
    Rep Power
    0

    Default Re: CMD Issue

    Quote Originally Posted by DarrylBurke View Post
    What's your OS?

    db

    edit To get better help sooner, post a SSCCE (Short, Self Contained, Compilable and Executable) example that demonstrates the problem.
    Windows 7 Home Premium

    http://www.mediafire.com/?29o6vx1rqklmdll

    That's the .jar file if anyone wants to try :)
    Last edited by Gee; 01-20-2012 at 11:10 AM.

Similar Threads

  1. How do I fix this issue?
    By m4mm4l in forum New To Java
    Replies: 8
    Last Post: 11-17-2011, 03:49 AM
  2. JSP issue
    By RamaLakshmi in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 01-21-2011, 01:55 PM
  3. nio issue
    By mawandiadeepak in forum Networking
    Replies: 2
    Last Post: 03-17-2010, 05:23 AM
  4. JSF issue
    By premjo in forum New To Java
    Replies: 0
    Last Post: 02-14-2010, 02:19 PM
  5. Issue
    By FlashNinja in forum New To Java
    Replies: 20
    Last Post: 11-28-2009, 09:44 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
  •