Exiting the program

Hi all,
I catch all checked exceptions in my Java code. I want that my program terminates if an execption occurs (like an SQL exception). Is it safe to use System.exit(0) in the catch block to terminate the program? Is it safe and enough to stop the currently running Java Virtual Machine that way?
The Java documentation syas: "...a nonzero status code indicates abnormal termination. "
Does it mean I should use a nonzero code? Like: System.exit(1) or since it's my will to terminate the program, the zero code will do the job?
Any help is greatly apprecited.

It's fine if you want to use system.exit()
The codes are just returned to the calling program, for example if you made a batch file to run your java program
java myprogram
if errorlevel == 1 @echo Your program bombed... HAHAHAHAHA...

Similar Messages

  • After sorting photos into albums, the albums disappeared on me. I dragged and dropped the photos and went back to check that they were in place before exiting the program. When I went back, the folder was there but no albums. Help!

    Working on an IMac - with IPhoto v.9.6 
    This is my first experience with IPhoto... trying to move files from a PC over to a Mac.
    I don't have a ton of photos but I created about 6 albums - standard albums - and dragged and dropped individual photos into each of the albums. I named each of the albums as well so I would know what was in each. After i was finished, I created a folder called 2014 and moved each of the albums into that folder. Before moving ANY of the albums, I opened each of them up to make sure that all the photos I wanted in each were indeed there - and since there were some errors on my part, I deleted any duplicates first. SO, I KNOW the photos were actually in each of the albums BEFORE i moved them into the 2014 folder.
    My intention was to then delete the photo files in my document file but once I got there I thought I would go back and double check the IPhoto file just to make sure... and the pictures were NOT in the albums where I had placed them... is there a need to save this before you move on and if so, to where and how? I was under the impression that once files were moved to albums, they remain there.
    The photos are still in the photo library but unsorted now again... I cannot even open the 2014 folder at this point.
    Thanks for any help!!

    Was back on IPhoto this morning. The folder did not open at all so I deleted it. Beside Albums, nothing showed at all. It was like I had done no work at all except to import my photo folder. Nothing was in my trash bin either.
    I started again and created one album at a time. I dragged and dropped photos into the album and exited out of IPhoto, opened up other programs and then returned to IPhoto to see if the album was still there and it was this time. I created a second album and did the same thing. This time, for some reason, the albums seem to be staying in place. I am not doing anything differently than last time. After creating three albums, I created a folder called 2014 and dragged and dropped the three albums into the folder and exited IPhoto. They were still there when I returned - YEAH! It seems to be working - for now! I am keeping my fingers crossed that my photos are not going to disappear but I am not going to delete my photo folder from my files just in case!
    Thanks for the suggestions but this may just have been a funny glitch... not sure what happened. I didn't change anything or do anything differently this time except that I am doing it one album at a time and exiting the program between creating each of them and coming back to check... very strange.

  • My safari screen suddenly fills my entire screen, and there is no right hand corner button to push to manually shrink it. What to do? I can never even exit the program without quitting it.

    My screen when I am using Safari suddenly fills my entire screen, and there is no right hand corner button to push to manually shrink it. What to do? I can never even exit the program without quitting it.This has happened only within the last two days.

    Try changing the screen resolution.
    Go to Apple Menu / System Preferences / Displays.
    Change the resolution. Whatever numbers are shown, e.g. 1280 x 960, select a larger one. The larger the number, in the resolution the smaller the display on the screen. You can keep changing this till you find the resolution that suits you.

  • Hi when i use treeMap class and if i exit the program

    hi
    hi when i use treeMap class and if i exit the program,
    what will happen? the information that i put in the treeMap will be disappear??
    if it is like that,,how am i able to retrieve my data...when i restart my program..
    once i put ID as key and put my customer information,
    in it, after exit my program,, and i can't find
    my customers by their ID,,,,,,,,,how can,,i solve it......

    what will happen? the information that i put in the
    treeMap will be disappear??Yes. Of course. If you want data to hang around you have to tell the computer. If you want anything to happen you have to tell the computer.
    if it is like that,,how am i able to retrieve my
    data...when i restart my program..Tada! Tell the computer. Your simplest option is to use Serialization.
    Before exiting your program, serialize your TreeMap to disk. After starting your program serialize your TreeMap from disk.
    First stop should be your text book to learn what Serialization is and how it works, then try to write some code, then ask us to help with any problems.
    Dave.

  • How to exit the program using AS3??

    Hi guys  , i'm trying to use a button to exit the program. anyone knows which code to use?

    What exactly do you mean by 'exit the program'? What program? Is your Flash Object in a browser, or is it an AIR app?
    If you're talking about an AIR app, have a look at:
    NativeWindow.close()

  • ITunes 9 Dumps music library when exiting the program

    I would sure appreciate any help that you all might be able to throw my way. Upgraded to iTunes 9 a couple of months ago. Basically from the time it was installed I have had the problem that I must Manually click FILE and Add Folder to Library. Upon exiting the program it will then basically dump the whole library and the next time I open iTunes I have to Add Folders to Library Again. After the upgrade to 9 I didn't even try syn'in my Nano because I was afraid I might loose music so I just left it alone and kept fiddling trying to figure out why the library would dissapear upon exiting the program.
    Just after Christmas I got a 16GB Touch so figured I really need to get the figured out..... and I'm still trying. Before connecting the Touch for the first time I COMPLETELY uninstalled iTunes, Quicktime, Apple Software UPdater, Apple Mobile Device Support, Bonjour,etc. After this, I found i still had an itunes folder in my Music folder so I deleted that (I pulled purchased music files into a seperate folder on my desktop just in case). I reinstalled itunes 9, went to File and then Add Folder to Library and imported everything. I wanted to get up and running with the Touch so I made a couple small playlists and called it a day. Exited the program, then re-opened it just to check if it was still there and it was! I was excited..... but not for long. Next day opened iTunes 9 and there was no music, the library was empty.
    I could go on and on... but won't. I've read posts about checking the XML file in wordpad, which I've done and seems like it's correct. even when I go to Preferences/Advanced, and look at where it's storing it seems correct.
    Can some one point me where to look?????
    Thx! Jeromy

    Thank you so much for your reply Katrina. Interesting stuff. Somehow in the mega searches I was doing for answers I didn't think to search using the Vaio angle. I will definitely go through those Vaio Files. This is my 4th Vaio and I NEVER seem to use any of the preloaded software, but to this point have not had problems until I installed iTunes 9.
    Last night I read another post that reminded me that the music files that show up in the iTunes/music folder are just "pointers" or say "shortcuts" (I can't remember the actual term used) to where the ACTUAL music files are located. When I used the Add Folders from the file menu I've always assumed that these "shortcuts" have been placed in the iTunes/Music folder properly. But just in case, I clicked on the Copy Files to iTunes Media folder in Advanced tab to be safe and then I did the Drag/Drop from my windows MY MUSIC folder (rather than using the Add Folders to Library in iTunes). I started by dragging and dropping like 5 albums. Then I'd close, open, close, open etc. to see if they would stay in my iTunes music library.... and they DID! So I left it overnight and then this morning I dragged a bunch more albums into my iTunes music library. Did another close, open, close, open on iTunes and so far everything is staying in place. My next test is going to be to completely shut down my Vaio and start it back up and see if it's all still there.
    Do you think any of this makes sense, or relates back to the Vaio software issues from the post you provided? I don't quite understand why it would work to drag/drop but not simply click Add Folders to Library???
    Thanks Again,
    Jeromy

  • HT1349 I have registered my serial number but cannot continue the download because it says that the number already exists. This happened when I previously entered the number bt had to exit the program. How do I resolve this?

    I have registered my serial number but cannot continue the download because it says that the number already exists. This happened when I previously entered the number bt had to exit the program. How do I resolve this?

    Leigh...
    but cannot do this because I cannot access Mac App Store
    If you can't access the App Store from the Apple menu, Dock, or Applications folder installing the Mac OS X 10.6.8 Update Combo will reinstall the App Store for you.
    It's ok to do this even you are already running v10.6.8.
    Plants vs. Zombies, and that is all for additional software on here
    FYI:  Some third party software can cause issues with the App Store >   Mac App Store: Sign in sheet does not appear, or does not accept typed text
    Apple is not responsible for incompatibility isssues with third party software.

  • Hi i want to exit the program if no file found by FM call file_get name

    HI
    I am calling a function module which is picking up a file from utility server
    presently its giving error message that if no file found it propts for error msg no file found or file could not be opened i suppose  its coming by the FM only
    now i want to write a code that if there is no file then the program should exit and not execute further but with no error mesage
    pls suggest a code for this
    regards
    Arora

    Hi Nishant,
    Try to do as indicated in the following code below
    FORM validate_app_file USING  fp_file  TYPE FILENAME-FILEINTERN.
      data : l_fname(60).
      CALL FUNCTION 'FILE_GET_NAME'
        EXPORTING
          LOGICAL_FILENAME = P_FILE
          OPERATING_SYSTEM = SY-OPSYS
        IMPORTING
          FILE_NAME        = L_FNAME
        EXCEPTIONS
          FILE_NOT_FOUND   = 1
          OTHERS           = 2.
      IF SY-SUBRC = '0'.
        OPEN DATASET  L_FNAME FOR INPUT IN TEXT MODE ENCODING DEFAULT.
        IF sy-subrc NE 0.
          MESSAGE s007 DISPLAY LIKE c_e.
        ELSE.
          CLOSE DATASET l_fname.
        ENDIF.
      ENDIF.
    Also find below the parameters for the function module and thier use
    Interface of function module FILE_GET_NAME
    IMPORT parameter
    Function
    CLIENT
    Logical file names can be client-specific. Here you can specify the client to be used. The current client as stored in the system field SY-MANDT is used as default.
    LOGICAL_FILENAME
    Here you specify the logical filename. (Uppercase letters must be used!)
    OPERATING_SYSTEM
    Here you can specify the operating system for which to generate the appropriate file name. The application server's operating system as stored in the system field SY-OPSYS is used as default.
    PARAMETER_1
    PARAMETER_2
    Here you can specify values that substitute the placeholders <PARAM_1> and <PARAM_2> in physical file names and paths.
    USE_PRESENTATION
    _SERVER
    Specifies that the presentation server's operating system be used as the basis for generating a platform-specific file name.
    WITH_FILE_EXTENSION
    Specifies that the logical file name's data format be used as filename extension.
    USE_BUFFER
    Specifies that the customizing tables for converting platform-independent file names be buffered in main memory.
    EXPORT parameter
    Function
    EMERGENCY_FLAG
    If the returned value is not SPACE, then no physical path has been found for the logical filename under the current operating system. In this case the path specified in the profile parameter DIR_GLOBAL will be used as physical path.
    FILE_FORMAT
    Returns the data format defined for the logical file name. You can use this parameter to decide in which mode to open the file. It is also required as a parameter for DOWNLOAD of files to the presentation server.
    FILE_NAME
    Returns the fully instantiated platform-specific file name and path.
    Exceptions
    Function
    FILE_NOT_FOUND
    Raised if logical file name is not defined.
    OTHERS
    Raised if other errors occur.
    Analyse your problem
    If the function module cannot find a physical path for the current operating system (see parameter EMERGENCY_FLAG), this may have various causes:
    the operating system is not defined in the customizing tables
    the operating system is not assigned to a syntax group
    no physical path is assigned to the logical path for the relevant syntax group
    no logical path is assigned to the logical file name.
    Please check and revert
    Also Reward points for all helps.it encorages others to help u more
    Regards
    Byju
    Edited by: Byju Edamana on Mar 20, 2008 11:06 AM

  • How to the get the count even after we exit the program and start again.

    Hi,
    I have a DAQ program which takes scans every 3 sec, scan number is incremented is been tagged with the filename of each scan. What my requirement is to save that scan number somewhere and get that number the next time I start the program, hence there is no repeatation of the scan numbers ever and I always end up having sequential scan files.
    One solution which came to my mind is to save that number in the computer as excel or txt file and read back again the next time I start the program. I am just wondering if there is any better way of doing it.Please let me know.
    Thanks,
    Ankit

    well ,
    you can get an array of the files in the directory and scan for the highest number....
    or use the the ini-file vis to write that number before exit (or after each file written)
    here I first wrote the key  ... however I hope you got the key
    Greetings from Germany
    Henrik
    LV since v3.1
    “ground” is a convenient fantasy
    '˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'

  • Save into a file before exiting the program

    Hi All,
    I am developing a java project. It is a console application.
    Initially the program loads content of a file(customer.txt) into an ArrayList.
    Then it gives 3 options:-
    1. Add a Customer
    2. Delete a Customer
    3. Save and Exit
    The changes add or delete are made in the ArrayList.
    The ArrayList is saved back to the customer.txt only when we select the option 3.
    It works fine.
    But instead of exiting the application using option 3, if we close the eclipse window or restart the computer, the changes are not saved to the file.
    So could you please suggest me how we can save the changes in such situations.?

    - Create a class that extends Thread
    - in the run() method place the code that saves your data
    - in your initialization create an instance of your Thread class but do not start it - instead register the object as a shutdown hook (use Runtime.getRuntime().addShutdownHook()).
    When your application terminates the VM will kick off your thread, which should save your data. You may have to experiment a little to get it working right. Remember that only a normal termination signal will allow the VM to continue running so that it can execute your shutdown thread - a kill signal will stop the VM, as will calling Runtime.halt().
    (Edit: note also that this may not work in Eclipse - I've seen problems running shutdown hooks when testing an application under Eclipse.)
    Edited by: PeteFord on Nov 17, 2008 1:39 PM

  • Exit the program ,when the condiiton fails

    Hi Experts,
    I want to leave leave the program it self ,
    if the condition fails indise the nested if statement.
    I have tried using exit statement in nested if condition, but it is exiting the current loop.
    Thanks in Advance
    Regards,
    Irfan

    Hi,
    My problem is like this
    if cntry eq 'us'
    if condition 1.
    sy-subrc eq 0.
    proceed.else terminate the program.
    if condition 2.
    sy-subrc eq 0
    success
    else
    leave the program.
    elseif cntry eq 'de'
    same as  above.
    else.
    if cntry ne 'de'.
    same as above.
    endif.
    Please help me out.
    Thanks in Advance
    Irfan Hussain

  • How do I exit a procedure without exiting the program?

    I just want to exit a procedure so that I do not execute the rest of the code below the point of where I would like to exit the procedure. Is there anyway I can do this?

    Here is a clever bit of code that only makes sense if you have ever had multiple blocks and didn't want to exit with multiple return statements.
       boolean isOk = true;
       do  // Only do everything in here once.
          // This is a clever bit of code that allows us
          // to only have one exit point.
          isOk = step1();
          if (!isOk) break;  // This is the clever part
          isOk = step2();
          if (!isOk) break;  // This is the clever part
          isOk = step3();
          if (!isOk) break;  // This is the clever part
          } while (false);  // Yes, false

  • Adobe 10.1.7 will not close in task manager after you exit the program. High cpu

    Hello,
    Updated to 10.1.7 and noticed that when you close the program an instance of acrobat stays open in task manager with high 50%+ cpu usage. Will not close at all unless you end task. if you open adobe again a new instance opens again consuming more cpu and cripples the machine with high cpu. This is on win 8 64bit machine. Had the previous release 10.1.6 working for some time on the same machine with no issues.
    Thank you in advance

    Identical issue with Acrobat XI Pro on Windows 8 Pro 64 bit. After viewing PDF file, upon closing Acrobat, a new Background Process starts called Adobe Acrobat (32 bit) uses 18% of cpu.  I have left run for three to four hours and does not close.  If I open another PDF file and then close, a second Background Process of Adobe Acrobat (32 bit) start, also using 18% of cpu.  I was able to open a third PDF file and upon closing a third Background Process of Adobe Acrobat (32 bit) start, also using 18% of cpu.  I did not try more.  All three consume over 50% of processor and after an hour does not close.  Fan and cpu begin to run hot so I manual End Task.  I tried Repair Acrobat Installation command, did not fix.  After searching forum used the Adobe Reader and Acrobat Cleaner Tool (http://labs.adobe.com/downloads/acrobatcleaner.html) to uninstall.  Then downloaded Acrobat XI Pro from My Adobe account login.  Reinstalled software.  Issue gone, could not replicate even after several hours of trying.  Then Checked for Updates. After updates installed, loaded and brought to version 11.0.3, problem returned as before. I have PDF files on both local drive and NAS, been able to recreate issue on both.  In a PDF intensive environment, I was having to leave the task manager up and occasionally stop Background Process of Adobe Acrobat (32 bit) so as to keep processor usage and fan speed down, thanks to Goateye01 for the suggestion, I now leave Acrobat open and close the files, this way the background process hang does not occur.  Additional Note, only able to create issue with standalone application, issue does not occur when in IE10 and viewing PDF files.   Hopefully a fix or helpful guidance coming soon?
    Vaio model SVS151290X
    Intel Core i7-3632QM [email protected]
    12 GB Ram
    256 GB SSD

  • Why do I lose my "Groups" after I exit Firefox? How can I get them to remain for my next session. I exit the program through the Firefox tab.

    I am running Windows 7 on my laptop, and lately when I close Firefox (under the Firefox tab with 'exit' ), the groups I have created do not reboot the next time I sign onto Firefox. What do I need to do?....I have even checked the "History" options but I can't find a way except to reload ezch page individually. Help!

    Are using "Clear history when Firefox closes" ?
    *Tools > Options > Privacy: History: [X] Clear history when Firefox closes > Settings
    *https://support.mozilla.org/kb/Clear+Recent+History
    It is possible that there is a problem with the files sessionstore.js and sessionstore.bak in the Firefox Profile Folder.
    *http://kb.mozillazine.org/Session_Restore
    Delete the sessionstore.js file and possible sessionstore-##.js files with a number and sessionstore.bak in the Firefox Profile Folder.
    *Help > Troubleshooting Information > Profile Directory: Open Containing Folder
    *http://kb.mozillazine.org/Profile_folder_-_Firefox
    Deleting sessionstore.js will cause App Tabs and Tab Groups and open and closed (undo) tabs to get lost, so you will have to create them again (make a note or bookmark them).
    *http://kb.mozillazine.org/Multiple_profile_files_created

  • How to reset all the entries wo exiting the program

    Hi How to reset all the entries from the third and last wrong entry and back to first entry wo closing program. It works with the first and second wrong entry, not for third wrong entry.
    Attachments:
    access.vi ‏59 KB

    The reset button does not work because when anything is entered in the operator field, and you press "reset", two events occur (1) a change is detected in the operator field and (2), a change in the reset is detected. Event (1) occurs first stopping the loop. The reset case is thus never reached.
    One solution would be to sense the reset state in the "operator" event. You need to keep the loop running if reset is pressed. (See attached modification.)
    Some other suggestions: Notice that I also made a data dependency between the case structure and the while loop. Without this, there is no guarantee that the case structure executes before the while loop and you might generate a race condition with unexpected results. I also re
    moved the timeout event, it doesn't seem to do anything. The three text fields should be set to "limit to single line" in this application so fields can be finished by hitting the enter key).
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    accessMOD.vi ‏65 KB

Maybe you are looking for