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

Thread: java app

  1. #1
    nhrnjic6 is offline Member
    Join Date
    Sep 2012
    Posts
    5
    Rep Power
    0

    Default java app

    i have created java program, converted it to .exe and its runs with no problem. Only problem i have is when the program finishes last line of code program closes imidetly. So can u tell me what function to use to stop it form closing same second as its finished

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,816
    Rep Power
    25

    Default Re: java app

    By "closing" are you talking about a window closing?
    If you don't want the program to exit to the OS, don't call the System.exit() method until the user closes the window.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    nhrnjic6 is offline Member
    Join Date
    Sep 2012
    Posts
    5
    Rep Power
    0

    Default Re: java app

    i never used that method.What i wanna do is when my program finishes with its work to stop, not to close, because i never get to see my final result?

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,816
    Rep Power
    25

    Default Re: java app

    Does the program display its results on the console
    or in a GUI window?

    What do you mean by "close"? What happens when you execute the program? What happens when the program finishes?
    If you don't understand my response, don't ignore it, ask a question.

  5. #5
    nhrnjic6 is offline Member
    Join Date
    Sep 2012
    Posts
    5
    Rep Power
    0

    Default Re: java app

    Its console. It exits the OS like you said it, but I want program to stop and me to close it with the x button on the top when i decite to

  6. #6
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: java app

    This is more of an OS issue than a Java issue. If you're running on Windows, you could create a command window by calling cmd.exe, then calling your program from the command window. Then the window will stay open until you type in exit.

  7. #7
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,816
    Rep Power
    25

    Default Re: java app

    Another option would be to use the Scanner class. It could try to read from the console with a next method that would block execution of the program until the user entered something.
    Fubarable likes this.
    If you don't understand my response, don't ignore it, ask a question.

  8. #8
    nhrnjic6 is offline Member
    Join Date
    Sep 2012
    Posts
    5
    Rep Power
    0

    Default Re: java app

    thanks, its a great idea :)

  9. #9
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,816
    Rep Power
    25

    Default Re: java app

    Btdt
    If you don't understand my response, don't ignore it, ask a question.

  10. #10
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,455
    Rep Power
    20

    Default Re: java app

    nhrnjic6, please go through the Forum Rules -- particularly the third paragraph.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Posting Permissions

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