How to run function(s) on ANY program exit?

I can easily do this when someone selects "Exit" from the program's menu, with this code:
AllSortsOfExitCode()
System.out.println("Ok, everything is wrapped up. Now we will end the program.");
System.exit(0);
BUT...how do you get this code to run when someone clicks the little X in the upper-right hand corner?
I can't figure out how to do that.
I need to override the class destructor or something, but I don't think Java has destructors in the classic sense. I found one 4-page thread about "Java destructors" but it was just an argument between a couple people -- I didn't learn anything from it.
Thanks,
Matthew

CathInfo wrote:
BUT...how do you get this code to run when someone clicks the little X in the upper-right hand corner?
Thanks,
MatthewThe earlier replies cover the case you described above. But your thread title says something else:
How to run function(s) on ANY program exit?Answer - you can't. Power loss can't be handled. Shutdoen hooks can help with most other conditions, see
http://www.google.com/search?num=100&hl=en&c2coff=1&q=java+shutdown+hook&btnG=Search

Similar Messages

  • How to run custom Oracle report6i concurrent program in web forms

    I developed a custom report using oracle6i and registered into AOL and assigned to a request group. I can run this concurrent program from form based application works fine. How to run this concurrent request from web forms?
    What are the steps to follow to create a concurrent program link on web forms?
    I want run this request and pass parameters and output also in web forms...
    I'm a first time user of web forms, So kindly reply with detailed steps to define concurrent request in web forms for a custom report.
    Thanks in Advance
    Naveen
    [email protected]

    I hope ur requirement to do all the CP processing from Self-Service OAF pages. If so,
    browse thru Re: Start Concurrent from OA Framework page , Re: RE: Submitting concurrent request and getting the results back.
    and
    'Concurrent Processing: Request Submission and Monitoring' section in dev guide.
    Let us know if you face any issues in the implementation.
    - Senthil

  • How to run performance trace on a program

    Hi All,
          I need to run pefromance trace on a program that I will run in background. I think I have to use ST05 to run SQL trace. Could someone please confirm the steps?
    1) Go to ST05
    2) Activate trace with filter
    3) Run the program in background
    I am not sure about the steps after this. How do I view the report while trace is running? Should I wait till the program ends to view the report? It is taking a long time to run. Should I do any other performance analysis other than ST05?
    Thanks.
    Mithun

    Hi Mithun.
    I would like to suggest a few references,
    [SDN Library - Standard Reference - How to analyze performance problems - Trace|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/3fbea790-0201-0010-6481-8370ebc3c17d]
    [SDN Library - Standard Reference for Performance Analysis in a Nutshell|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/86a0b490-0201-0010-9cba-fd5c804b99a1]
    [SDN Library - Standard Reference - Best Practices for Performance Tuning|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/5d0db4c9-0e01-0010-b68f-9b1408d5f234]
    Hope that's usefull.
    Good Luck & Regards.
    Harsh Dave

  • How to run functions when changing states?

    Hi everybody
    I want to run function when changin states
    For example I change my state and write something on Panels title and when this state appears i want to read my title and to do smth
    How can I do it. Where is my mistake?
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application
        xmlns:mx="http://www.adobe.com/2006/mxml" verticalAlign="middle"
        width="340" height="250"
        layout="absolute"
    currentStateChange="StateChangez();">
    <mx:Script>
    <![CDATA[
    public function StateChangez():void
    if (currentState=='a')
    //Alert.show('a');
    if (Panel1.title=='New')
    Alert.show('New');
    else
    Alert.show('Edit');
    else
    Alert.show('b');
    ]]>
    </mx:Script>
    <mx:states>
      <mx:State name="a">
       <mx:RemoveChild target="{button1}"/>
       <mx:RemoveChild target="{button2}"/>
       <mx:AddChild position="lastChild">
        <mx:Panel x="0" y="40" width="340" height="210" layout="absolute" id="Panel1">
        </mx:Panel>
       </mx:AddChild>
       <mx:RemoveChild target="{button3}"/>
      </mx:State>
      <mx:State name="b">
       <mx:RemoveChild target="{button2}"/>
       <mx:RemoveChild target="{button1}"/>
       <mx:RemoveChild target="{button3}"/>
       <mx:AddChild position="lastChild">
        <mx:Label x="10" y="222" text="b"/>
       </mx:AddChild>
      </mx:State>
    </mx:states>
    <mx:Script>
      <![CDATA[
       import mx.controls.Alert;
      ]]>
    </mx:Script>
    <mx:Button label="New" x="10" y="10" id="button1" click="currentState='a';Panel1.title='New';"/>
    <mx:Button x="68" y="10" label="Edit" id="button2" click="currentState='a';Panel1.title='Edit';"/>
    <mx:Button x="10" y="218" label="b" click="currentState='b';" id="button3"/>
    <mx:Button x="265" y="10" label="Read" click="StateChangez()"/>
    </mx:Application> 
    Message was edited by: AtomicRussian

    Hi,
    I think your event handler "StageChangez()" is called before your Panel title is set. Try first change title, then change currentState.
    Oh yes my mistake, you are adding it when state changes. You can put your Panel's title change in StageChangez() and after that you can do some actions.
    Regards,
    Adrian
    Message was edited by: AdrianWiecek

  • How to Run Function Modules.

    Hi folks.
    How do you run function modules?
    e.g.
    The function module
    RSBB_URL_PREFIX_GET will show information on URL prefix, path and server name in order to configure for web reports.
    I am trying to figure out  how to carry out the task step by step on BW system.
    Thank you.
    Kara.

    Hi:
    Test run in BW -
    go to transaction SE37
    RSBB_URL_PREFIX_GET
    give this info when you hit Test/Execute
    Handler class: CL_RSR_WWW_HTTP
    Protocal:
    Message Server: X
    Hit execute again.
    Chamarthy

  • How to run java older version java program with newer version 1.6.

    Hello frds.....i have a one query regarding jkd newer version. I was using older version of jdk 1.4 for my java program and projects' work. Now i installed newer version of java 1.6 in my machine, so when i tried to compile and run my older version programs in the newer version, its showing many errors. So can anybody helps me on this query that how can i run my older version java programs in newer version 1.6 or what types of changes i will be do in my java programs.
    Thanks in advance
    Kshitiz

    EJP wrote:
    so when i tried to compile and run my older version programs in the newer version, its showing many errorsI doubt it. There is only one incompatibility between 1.4 and 1.6, and that is the introduction of the 'assert' keyword. (or did that happen in 1.4?)I believe that was the one and only incompatible change made in 1.4.
    (Although I'm saying that from memory, and 1.4 was a long time ago -- so the "one and only" part could be wrong.)

  • How to run Perl script in Java program?

    Some say that the following statement can run Perl script in Java program:
    Runtime.getRuntime().exec("C:\\runPerl.pl");
    But when I run it, it'll throw IOException:
    java.io.IOException: CreateProcess: C:\runPerl.pl error=193
    at java.lang.Win32Process.create(Native Method)
    at java.lang.Win32Process.<init>(Win32Process.java:63)
    at java.lang.Runtime.execInternal(Native Method)
    at java.lang.Runtime.exec(Runtime.java:566)
    at java.lang.Runtime.exec(Runtime.java:428)
    at java.lang.Runtime.exec(Runtime.java:364)
    at java.lang.Runtime.exec(Runtime.java:326)
    at test.runPerl.main(runPerl.java:16)
    Exception in thread "main"
    Where is the problem? In fact, I do have a Perl script named "runPerl.pl" in my C:/ directory. Could anybody tell me why it can't be run? Thanks in advance.

    Hello sabre,
    First of all thanks for your reply.
    I have tried like what you mentioned.
    Eventhough, i could get the exact error message.
    I could get the Exception
    "Exception:java.lang.IllegalThreadStateException: process hasn't exited"
    <code>
    import java.io.*;
    public class Sample{
    public static void main(String args[]) {
    String s = null;
    Process p;
    try
         p = Runtime.getRuntime().exec("tar -vf sample.tar");
         //p.waitFor();
         if(p.exitValue() == 0)
              System.out.println("CommandSuccessful");
         else
              System.out.println("CommandFailure");
    catch(Exception ex)
         System.out.println("Exception:"+ex.toString());
    </code>
    In this code, i tried to run the "tar command". In this command i have given -vf instead -xvf.
    But it is throwing
    "Error opening message catalog 'Logging.cat': No such file or directory
    Exception:java.lang.IllegalThreadStateException: process hasn't exited
    CommandFailure"
    "Error opening message catalog 'Logging.cat'" what this line means ie,
    I dont know what is Logging.cat could you explain me its urgent.
    Thanks in advance.
    Rgds
    tskarthikeyan

  • How to run the simple java card program in eclipse?

    I am trying to run a simple HelloWorld program in eclipse 3.5 having java card development kit 2.2 installed in it.
    Firstly,I go to the JCWDE tab and press start..then when trying to deploy that package its giving me error like " com.hw.HelloWorld: unsupported class file format of version 50.0." can any one help me in this what is this error???n how to resolve n run this program..

    Hi,
    It is because the converter works on byte code and it only supports a subset of the Java language (see the JC specifications). It is kind of like compiling you code on Java 6 and trying to run it on Java 5. The JCDK outlines the required compiler version.
    Cheers,
    Shane

  • Mass Approval of Leave Request...need function module or any program

    Hi All,
    I have developed Custom Application in webdynpro java  for Leave,Travel,now i got the new requirements for mass approval of Leave and Travel can any baddy provide me any input ,i don't know which functional module or program i use , help gurus...
    Regards,
    Pramod gupta

    Refer below links to get an idea :
    uwl mass Approval- Select all option
    UWL Mass Approval XML changes or Custom App
    Mass leave approval?
    As an alternative to this service, you can use the Leave Request: Mass Approval report (RPTARQMASS_APPROVAL) in the back-end system. These reports enable you to approve multiple leave requests in batch.

  • How to run rmiregistry by my own programe ?

    Hello All,
    i make a simple rmi application i want ,
    when i start my rmiserver programe then it first run rmiregistry
    auto means by my programming.
    please any body help me.
    i m thnksfull.
    Arif.

    I didnt understand ur problem. U want to write your own registry and run it or simply u want to run an existing registry from ur program.
    If u want to run an existing registry from you program use following code in your program.
    Runtime r = getRuntime();
    Process p = r.exec("start rmiregistry");
    Make sure that "rmiregistry" is in ur PATH.
    Chatrapathy

  • How to run sscript shell with java program

    Hi everybody,
    i want to know how can i do to execute a script shelle (bash) with program java (if it s possible)
    for example this script:
    #!/bin/bash
    echo "hello"
    can i run it with java program or i have to make dome modifications .
    thank you for your help in advance.

    Well, if you want to be portable across platforms, you should write as much code in Java as possible and not rely on native scripts (I'm sure your script is more complex than this 'echo' example ;-) ).
    Having said that, you can use the java.lang.Runtime class and in particular its various exec() methods.
    Try something like this:
    Process p;
    try {
        p = Runtime.getRuntime().exec("myscript.sh");
    } catch (IOException ioe) {
    }You can then "interact" with the spawned process with the Process object returned by the exec method.
    Note you need to have the appropriate security rights.
    For more details, look at the API documentation here:
    http://java.sun.com/j2se/1.4.2/docs/api/
    hth,
    -Alexis

  • How to run form.html from any location i want.

    Hi all,
    This is my first post.
    i have just started to learn Servlets and JSPs..
    I made one form.html file with minimal contents and put it as tomcat/webapps/MyTest/form.html.
    while running it as was said in Head first servlets-> http://localhost:8080/MyTest/form.html..it is giving 404 error.
    And when i m putting it as tomcat/webapps/Root/MyTest/form.html
    then it is running fine as http://localhost:8080/MyTest/form.html
    Do i need to make any changes in server.xml. ???
    Please help.
    Thanks

    HOST command is a SQL*PLUS comand.
    you cant use that in PL/SQL . Note that PL/SQL executes at the server side (assuming a real client server environment at ur end)
    Also you cant issue a host commands using PL/SQL directly. Either you use the Java or some other technique
    We dont have such facility in PL/SQL to run a host command
    prakash
    [email protected]

  • How to run FLV file in any PC

    Dear
    I made a presentation in flash where I use some flv movie exported from aftereffect. so when I finally export a movie in swf from flash. I running perfectally on my PC coz I have adobe media player but If I send to client is not running on his PC though he downloaded flash player.
    So any one suggest what is the best option for this and if I want to upload the same on web do it will run any where easily.
    Cheers
    Aaman
    Graphic Artist 

    [Shameless plug]
    VideoLan Corp makes VLC Player which will play FLVs.
    It's free.
    It also plays WMV, MPG, MOV, MKV, AVI and a whole lot of other stuff.
    It also has the option during install to add a Mozilla Plugin for Firefox to play the supported formats.

  • How to run "Bing maps" in "ANY CPU" config in XAML?

    In sites, I see ,we need to change config to x86 or x64,to run Bing maps in xaml page
    I need my bing maps to run on a xaml page which has ANY CPU config.Please help

    The Bing Maps Windows Store control uses the C++ runtime. Any app that uses the C++ runtime and is written in C# or VB has to be compiled against each CPU. Any CPU is not an option. Several libraries from Microsoft have this requirement.
    Note that you simply compile your app against x86, x64, and Arm and then upload all three libraries to the Windows Store dev center. This will let users on all platforms access your app using any CPU.
    http://rbrundritt.wordpress.com

  • How to run function

    i created function to see output how should i
    thanks in advance

    you can
    select myfunction(params) from dual
    or if it inserts/updates/deletes then
    DECLARE
      v_out  <type of output variable>
    BEGIN
      v_out := myfunction(params);
      dbms_output.put_line(to_char(v_out) );
    END;

Maybe you are looking for