When does the JVM exit and deleteOnExit();?

I developed a JSP that queries a database, displays the results in a browser, and writes the results to the server as a file. While the user is viewing the JSP, they can click on a download link to save the file that was written to the server. Everything works fine!
I would like to delete the file that was written to the server (to save space), however, I can't delete the file until the user is finished viewing the JSP. I need some help concerning this method: java.io.File.deleteOnExit() the API states:
"Requests that the file or directory denoted by this abstract pathname be deleted when the virtual machine terminates. Deletion will be attempted only for normal termination of the virtual machine, as defined by the Java Language Specification (12.9)."
If I use this method, When does the JVM exit? I tested it in my home environment using Tomcat and the file was deleted when I stopped Tomcat. If I run this on a web server, does the JVM ever exit? If so when?
Thanks
--Scott

The JVM stays active so long as the Java based webserver (or the servlet engine if your webserver is connected to one) is up. Only when you shutdown your server will the VM terminate. (Similar to what you observed with tomcat)

Similar Messages

  • When does the JVM exit ?

    I am curious as to what could be the reasons when the JVM exits.Googling didn't give me much relevant links (my bad,may be !!).
    However the JLS states :
    A program terminates all its activity and exits when one of two things happens:
    1. All the threads that are not daemon threads terminate.
    2. Some thread invokes the exit method of class Runtime or class System and the exit operation is not forbidden by the security manager.
    Now,Are there any other reasons apart from the above that may result in a JVM to exit ? I would appreciate any pointers.
    Thank you for your consideration.
    Edited by: punter on Jan 4, 2010 4:14 AM

    Well, you already found the "normal" ways of exiting the JVM.
    punter wrote:
    Now,Are there any other reasons apart from the above that may result in a JVM to exit ? I would appreciate any pointers.It can also halt unexpectedly: crashing. By the very nature of crashes it's hard to define how exactly they happen. But they can happen.
    I assume that you could also call exit() (the C function) from native code, the JVM probably couldn't do much about that.

  • When does the Java main(String args[]) method exit?

    Hi all,
    I and my colleagues want to know, when does the main() method exit?
    we wrote a small code as follows:
    import java.awt.*;
    public class Test {
    public static void main(String[] args) {
    Frame f = new Frame("hi");
    f.show();
    System.out.println("after show");
    and ran the program, in which case I could see the printed message "after show", but although there is no code after the System.out.println(), the Java virtual machine does not exit and waits for the Frame to close.
    My question is has the main method exited in this case? since it clearly shows that it does not have any more code to execute. Does java create the main method as a thread or as a process?
    regards,
    Harshad

    To make your application terminate you need to add code to cause the AWT thread to handle the termination. In your code, before f.show(), try:
    f.addWindowListener(new WindowAdapter() {
      public void windowClosing(WindowEvent e) {
        dispose();
      public void windowClosed(WindowEvent e) {
        System.exit(0);
    });Now, at least you can click on the little "X" on the upper right-hand corner of the Frame (at least in Win95/98/NT) environments) to cause your application to receive a window closing event. It is also possible to add a menu with an option to exit; in that case I'd use an EventQueue to cause a window closing event to be sent.

  • I am currently using Lightroom 5.6 and operating on a Mac with OSX Ver 10.9.5. I am receiving an error problem when doing the following -  I am exporting selected photos from a particular Catalogue saved on Drive 1 to a folder created on another Drive whe

    Hi, I am having a little trouble with exporting images to another drive and Catalogue and need some help if anyone can give me some advice
    I am currently using Lightroom 5.6 and operating on a Mac with OSX Ver 10.9.5.
    I am receiving an error problem when doing the following -
    I am exporting selected photos from a particular Catalogue saved on Drive 1 to a folder created on another Drive where a Lightroom Catalogue has been created. In this Catalogue I have arranged for the images once exported to be moved to a different folder - I used the Auto Import process under the File dialogue box.
    When processing the Export I receive an error message for each of the images being exported indicating the following -
    Heading Import Results
    Some import operations were not performed
    Could not move a file to requested location. (1)
    then a description of the image with file name
    Box Save As                                  Box  OK
    If I click the OK button to each image I can then go to the other Catalogue and all images are then transferred to the file as required.
    To click the OK button each time is time consuming, possibly I have missed an action or maybe you can advise an alternative method to save the time in actioning this process.
    Thanks if you can can help out.

    Thank You, but this is a gong show. Why is something that is so important to us all so very, very difficult to do?

  • 1st generation ipod. When I plug it into my computer an image of a disk w/a magnifying glass appears (disk scan).  Each time I plug it in it does the same thing and it wont show up on my computer.

    I have a 1st generation ipod, which I love. When I plug it into my computer an image of a disk with a magnifying glass appears (disk scan).  When it finishes the scan it always checks out. I then restart it and all looks fine. Each time I plug it in to the computer it does the same thing and it wont show up on my computer. The other strange thing is all of the songs are gone from the ipod but the disk space is still being used. When the ipod is not plugged into the computer everything look fine even the correct date shows up. Any ideas????? Thanks

    try reinstalling iTunes.

  • How and When Does the attribute VI_ATTR_VXI_TRIG_STATUS get initialized

    How and When  Does the attribute VI_ATTR_VXI_TRIG_STATUS get initialized. Do the actual trigger lines get measured or does the attribute get initialized to a default value when the vxi resource manager is executed?

    Hey whl6868,
    According to page 157 (or 3-135) of the manual (http://www.ni.com/pdf/manuals/370132c.pdf), there is no default value for VI_ATTR_VXI_TRIG_STATUS.  If Resman is returning valid values for it, then it must be actually reading the lines.  Else, I would only expect it to return valid values when you actually call the function yourself.
    Regards,
    David R
    Applications Engineer
    National Instruments

  • When opening the Coloursync utility and pressing the verify button, I received an error message stating that the Tag 'cprt':Text tag has an incorrect length which could not be fixed as the file is locked. Does anyone know how to rectify this?

    When opening the Coloursync utility and pressing the verify button, I received an error message (copy below) stating that the Tag 'cprt':Text tag has an incorrect length which could not be fixed as the file is locked. Does anyone know how to rectify this?
    Checking 25 profiles...
    /Library/ColorSync/Profiles/Displays/iMac-00000610-0000-9C6C-0000-000004271B00.i cc
       Tag 'cprt': Text tag has an incorrect length.
       The file is locked. Could not be fixed.

    Hi guys,
    I followed the steps to unlock the .icc file in the "getinfo" screen then went on clicking repair in colorsync utility.
    This is the message i got:
    Searching for profiles...
    Checking 17 profiles...
    /Library/ColorSync/Profiles/Displays/Color LCD-00000610-0000-9CF3-0000-000004273CC0.icc
       Tag 'cprt': Text tag has an incorrect length. Fixed.
    Repair done - 1 profiles fixed.
    However, when i hit verify again it shows up like this:
    Searching for profiles...
    Checking 17 profiles...
    /Library/ColorSync/Profiles/Displays/Color LCD-00000610-0000-9CF3-0000-000004273CC0.icc
       Tag 'cprt': Text tag has an incorrect length.
    Verify done - found 1 bad profile.
    ... and it keeps like this sine die.
    when i open the .icc file it shows up like this:
    3     'cprt'     'text'     35     Copyright ASCII Text String
    New to mac so I really don't know what to do.
    I didn't get this message so far. What i did before getting this message was to open a jpeg file. I wanted to edit it so when i did right click on the file i went to open with, and colorsync came as an option; so i chose it.
    Then this message started comming up.
    Is there anything i can do?
    Thabks for the support.

  • When i change the hard drive does the admin user and pass change ?????

    when i change the hard drive does the adminstrator  user and password change ?????

    bin_bella wrote:
    when i change the hard drive does the adminstrator  user and password change ?????
    Yes, if you do a fresh install of the operating system, it's like a brand new machine.
    No, if you restore from a backup like a bootable clone or TimeMachine drive.
    Most commonly used backup methods

  • Data getting deleted when doing the validation

    Hi all,
    I have a web dynpro application to park an accounting document and I want the following functionality to it.
    When a user enters fund starting with 'P' then the cost center field should be greyed out and if WBS element field is not entered then I should see the error on the screen that it's a mandatory field.. For this I have written the following code:
    LOOP AT lt_el_tbseg INTO lo_el_tbseg.
        lo_el_tbseg->get_static_attributes(
                               IMPORTING static_attributes = lv_bseg ).
        CLEAR lv_bseg-lifnr.
        CHECK NOT lv_bseg IS INITIAL.
        TRANSLATE lv_bseg-geber TO UPPER CASE.
        IF lv_bseg-geber(1) = 'P'
                           *       navigate from <CONTEXT> to <EDIT_PROPERTY> via lead selection
          lo_nd_edit_property = wd_context->path_get_node( path = `Z_POSTING.CHANGING.T_BSEG.EDIT_PROPERTY` ).
    *       get element via lead selection
          lo_el_edit_property = lo_nd_edit_property->get_element( ).
          lo_el_edit_property->set_attribute(
            name =  `EDIT_WBS`
            value = 'ABAP_TRUE' ).
          DATA lv_projk TYPE wd_this->element_t_bseg-projk.
          IF lv_bseg-projk IS INITIAL.
            lv_error = 'E'.
            CALL METHOD lo_api_controller->get_message_manager
              RECEIVING
                message_manager = lo_message_manager.
            lv_message_string = 'WBS Element is a mandatory field'.
    *     report message
            CALL METHOD lo_message_manager->report_error_message
              EXPORTING
                message_text = lv_message_string.
            EXIT.
          ENDIF.
        ENDIF.
        wa_bseg = lv_bseg.
        w_amt_line = wa_bseg-dmbtr + w_amt_line.
        wa_bseg-lifnr = lv_lifnr.
        APPEND wa_bseg TO lt_bseg.
        CLEAR wa_bseg,lv_bseg.
    endloop.
    but right now two things are happening in correctly:
    1. It's doing the correct validation and throwing the correct error message but it's clearing out the content of the item table that user entered on the screen.
    2. it's not making cost center as an non editable field.
    can you please suggest me what I am doing wrong here.
    Thanks,
    Rajat
    Edited by: rajatg on Jul 7, 2011 4:04 PM

        report message
            CALL METHOD lo_message_manager->report_error_message
              EXPORTING
                message_text = lv_message_string.
            EXIT.
    your EXIT statement will get you out of the loop. rest of the records in internal table will nto be read

  • When does the program ends

    Hello,
    I have an application that opens a dialog in the "main" function and then the "main" functions ends
    when will the application exits ???
    Does it exit when the dialog cloed or when the main got to the last line??
    Thanks
    tamtamgol

    To give you the short answer, the last line of your
    main method. If you want the long version as to why,
    mail me and I'll explain :-)I'm guessing that the short version of the long version will be "Halting Problem"... :-)
    Dave.

  • ABAP Dump is encountered when doing the negative subsequent adjustment

    Hi Experts !!!
    An ABAP Dump is encountered when doing the negative subsequent adjustment (posting a 102 movt type) on a Purchase Order via the Z function module. The dump only happens if the scenario satisfies the following conditions:
    1.Material is either (but may not be limited to) 3000000234, 4000000121, 3000000210 (These are the only reported materials)
    2.Order unit in Purchase Order is in MT
    3.At 2nd weigh, Net Weight is less than PO Order Qty.
    Note: No error occurs if same process is done via MIGO.
    Initial Analysis:
    An exception/error occurs when calling function u201CMB_CREATE_MATERIAL_DOCUMENT_UTu201D .
    Please see below error anlysis report from after executin Zfunction module code.
    Error analysis
       Short text of error message:
       Material 3000000234 / US01 Column 0001: MSEG-BPMNG not in quantity table
       /not consistent
       Long text of error message:
        Diagnosis
            Before the system posts a material document for an HPM/TDP material
            (MARA-CMETH = 1 or 2), it performs the following consistency
            checks:
            o   For each unit of measure in the Unit of Measure Group
                (MARC-UOMGR), a line item  has to be present  in the additional
                quantity appendix table (Table MSEGO2)
            o   For each unit of measure in the main core table MSEG that is
                not initial a line item, has to be present in the additional
                quantity appendix  table (Table MSEGO2) and the corresponding
                packed format quantities have to be identical.
                This way, inconsistent stock level updates can be prevented.
        System Response
            The system stops processing.
        Procedure
            If the error is reproducible, contact your system administrator.
        Procedure for System Administration
            The inconsitency can have several reasons, for example:
            o   Incorrect postings from external systems using function module
                MB_CREATE_GOODS_MOVEMENT
            o   Handling errors
            o   Application programming errors
       Technical information about the message:
    Message class....... "O3"
    Number.............. 359
    Variable 1.......... 3000000234
    Variable 2.......... "US01"
    Variable 3.......... 0001
    Variable 4.......... "BPMNG"
    Please let me know,if you want some other details.

    Problem Issolved

  • I'm trying to use Dictation.  Where does the text go, and how can I retrieve it?  Thank you.

    I'm trying to use Dictation.  Where does the text go, and how can I retrieve it?  Thank you.

    You dictate after you open a blank page in any text editor. The text goes on the page.
    You can use Text Edit for example (in your applications folder).
    With the blank page open, go to the Edit menu and select Start Dictation. When you are finished, you save the file as you would any other document. You can retrieve it, edit it or anything else you want, because it is a file like any other you create with that text editor.

  • WHEN DOES THE IPHONE 5 COMING OUT IN SOUTH KOREA?

    WHEN DOES THE IPHONE 5 COMING OUT IN SOUTH KOREA?

    When it is announced by Apple. No one here would know. Go to Apple.com and watch the press releases to see when it will happen.

  • In which language does the jvm program is written?

    In which language does the jvm program is written?
    Please give the reason for that
    Thanks,
    Vidyadhar

    Dear Nisha,
    you can use table GRACREVREJUSER with the correpsonding reasons from table GRACREJREASON and GRACREJREASONT.
    Regards,
    Alessandro

  • When does the horizontalScrollBar get created on a List?

    When does the horizontalScrollBar get created on a List?
    The scroller is created, but the scrollbar isn't created yet and I get an error:
    I have a spark List:
    <s:List id="list" creationComplete="creationCompleteHandler(event)">
            <s:layout>
                <s:HorizontalLayout  />
            </s:layout>
    </s:List>
    private function creationCompleteHandler(event:FlexEvent):void {
         (event.currentTarget as List).scroller.addEventListener( FlexEvent.UPDATE_COMPLETE, onScrollerComplete );
    // these don't trigger anything!
    //    (event.currentTarget as List).scroller.addEventListener(FlexEvent.CREATION_COMPLETE , onScrollerComplete );
    //    (event.currentTarget as List).scroller.addEventListener(Event.ADDED_TO_STAGE , onScrollerComplete );
    private function onScrollerComplete(event:Event):void {
         // horizontalScrollBar still null at this point - how can I use it?   
         // I want to set the style, but it's not created yet!
         // event.currentTarget.scroller.horizontalScrollBar.setStyle("repeatInterval", 600);

    I just realized that
    this.setIconImage(new ImageIcon("image.jpg").getImage())
    did not create the icon for my saved files.
    So what did create it? I did not program it!
    However, I happen to have an icon file Ananya.ico where I have my java project. I use if for my installation file. Did Java use this icon?
    Please help! Thanks!

Maybe you are looking for

  • Problem in Sales Order Creation with reference to Contract

    Hi All, We had enhanced Contracts (VA41) by adding fields thru append structures in VBAP and the same is provided in the "Additional Data B" tab at the item level. The Z fields are populated with data and gets saved along with the contracts line item

  • File association with OpenOffice

    Hello, I'm a newbie to the Mac - well returning after many years. So, the questions revolves around having files with .doc extension open with Open Office vs, the preinstalled trial version of MS Word. Does not appear to be a setting in Open Office,

  • I am leaving for Japan on business and I have no service since the upgrad, what are you doing to fix this problem Apple.

    What am I supposed to do. I am leaving for Japan on business on Monday and your upgrade has screwed up my IPad. "No Service", how can I rely on your products for business!  Apple more than anyone should know what happened to Blackberry. did anyone te

  • SC : Extended  Search on Header Customer field

    Hi , I have created customer defined field on Header & Item in SRM 5.0 . I am showing both of them on Extended Search in Check Status of Shopping Cart . But I can search on the basis of Item Customer field <b>not</b> on the basis of Header Customer F

  • How we know the selected node in a Tree object in a form?

    In a TREE object in forms, how can we know the current selected node by clicking a push button. lets say , there are 10 nodes in my tree, and 5th one i selected. But i want to store the selected node in a variable, when i click a button. please help