How  to track System.exit(0) call

hi there,
how can i trace the System.exit(0) function call in my program.
i.e as we know which class is being loaded into the jvm by overriding
the classloader, can we similarly know when is our jvm going to be
destroyed. here iam invoking jvm from my windows program using invocation api.
any help is mostly appreciated.
thanks in advance
bye
ramana

Not sure I know what you are asking.
You could create a security manager which prevents exit() from being called.
You could replace System using the bootstrap command line option. Although if you do that you can not distribute it due to the license agreement. Once replaced you can do anything you want in the application.
You could use Runtime.addShutdownHook() if you just want to do something when the application exits.

Similar Messages

  • How to track error message when calling Transaction: va02

    Hi all,
        As we all know, when we change an order through T-Code: VA02, system will update modified data to corresponding database. Meanwhile, if our operate is not legal or incorrect on T-code: VA02, system will call corresponding error messages to us.
        Now I want to know:
       1. how to track the error messages
       2. Is there any Tcode such as: SM21 that we can see the message logs after our operation?
    Thanks.

    Hi ,
    message table for call transaction
    DATA: BEGIN OF G_T_MSG OCCURS 0.
            INCLUDE STRUCTURE BDCMSGCOLL.
    DATA: END OF G_T_MSG.
    Exucute transaction via Call Transaction
      CALL TRANSACTION  'FB01'
                     USING g_t_bdcdata
                     MODE g_l_mode
                     UPDATE 'S'
                     MESSAGES INTO g_t_msg          .
    errors will be stpored in the table g_t_msg ..
    Thanks .

  • Catching System.exit() or How to avoid System.exit() - Third Party Tool ???

    Hi All,
    I am using a third party tool which is internally calling System.exit sometimes and my application
    got terminated most of the times.
    It is happening always when i call a particular method of that third party tool.
    Is there any way to catch or avoid the System.exit while using the particular method?
    I need this urgently...Please kindly help.....
    Thanks,
    J.Kathir

    There's a fair bit to it, and you should refer to the appropriate java Tutorials. Bascially you create a .policy file and install a sercurity manager with:
    System.setSecurityManger(new SecurityManager());The policy file grants a set of permissions to various "code sources", basically each codesource is a classpath entry. You could grant "AllPermissions" to your own code, and a more restricted set of permissions to the application you're running. But you can't subtract permissions, i.e. you can't say "this code can do anything except call System.exit().
    I doubt this is going to provide you with a good solution. It's tiresome to set up, and when the client app called System.exit it would crash, which might not result in a clean status.
    I'd consider if you should be using this client app in the same JVM, rather than creating a subordinate JVM using Runtime.exec.

  • How to track application exit event?

    I have my swf embeded in Asp.Net. I want to track application exit event. Is there any event which is called when flex application exists or unload or destroyed? I tried application close event but it is not working. I do not want events of browser close or etc because I already tried it.
    Thanks,
    -Chandu

    if you wanted to just close the window all together you could write some Javascript to close the window, then in your flex app call the function when they click the logout button
    If you want to actually end it with Actionscript you could try:
    public function applicationExit():void {  
         var exitingEvent:Event = new Event(Event.EXITING, false, true);  
         NativeApplication.nativeApplication.dispatchEvent(exitingEvent);  
         if (!exitingEvent.isDefaultPrevented()) {      
              NativeApplication.nativeApplication.exit(); 
    Source: http://livedocs.adobe.com/flex/3/html/help.html?content=app_launch_1.html
    UKB

  • NoClassDefFoundError after System.exit() is called.

    I have found a strange condition with JDK 1.4.2_05 and could not find a bug which relates to it.
    I have multiple threads running, when I shutdown, I call all the threads to shutdown and finally in main I call System.exit(0).
    The strange thing is that one shutdown I get a NoClassDefFoundError for a class which will load fine if loaded before shutting down.
    This occurs as the class in question is only needed to perform a shutdown, and in fact the attempt to load it comes after the main thread has finished.
    The workaround has been to create an instance of the class when the application is started rather than during shutdown.
    Does anyone seen this behaviour?

    java.lang.NoClassDefFoundError: com/cantor/framework/run/impl/ShutdownRMB
         at com.can.framework.run.RunnerManagerBean.shutdown(RunnerManagerBean.java:147)
         at com.can.framework.layer.VanillaBean.shutdown(VanillaBean.java:278)
         at com.can.main.Main.main(Main.java:135)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:324)
         at com.intellij.rt.execution.application.AppMain.main(AppMain.java:78)

  • How to intercept "System.exit"?

    I am writing a large GUI application that optionally spawns other GUI threads. These spawned threads are special-purpose text editors. It is important that the editor knows when it is about to be closed, so that it can prompt the user to save a modified file.
    The editors are based upon javax.swing.JFrame, and I have overridden the "windowClosing" method of a WindowAdapter to check file status and prompt when necessary. This method performs as desired when I close the editor window manually. However, when I close the main application (which calls System.exit(0) ), the editor frames also close without any invocation of my windowClosing method.
    Is there any way the dependent editor JFrame can be alerted that the virtual machine is about to be ended? I could probably keep a list in my main application of all the dependent processes that need to be cleanly ended, but it would be much simpler (and so much more object-oriented) if the dependent thread could take care of itself!

    MarkHausman wrote:
    As you suggested, I posted this question on the Swing forum.
    For those who are interested: the Swing solution I was offered was to make use of the static function Frame.getFrames(). This allows access to all frames launched by an application. By putting this call in my main shutdown method, I can identify all spawned editor frames and call each one's shutdown method.
    This is not as satisfying as my original desire, to have the spawned frame recognize when the VM is about to close, but it is easy enough to implement that I am going with it.And why wouldn't addShutdownHook() work?

  • How to track system users?

    Hi Gurus,
    Can anybody tell me how can we keep track of WF-BATCH user? We need to know immediately if the user got locked or was stopped due to problems. Please suggest ways how we automatically track the WF-BATCH user.
    Thank you

    Hi Juan,
    Even security audit alone may not necessarily may not help coz you need to go and keep on checking it. Well in that case simply checking SU01 on regular basis might solve the issue )
    What is required is CCMS alert kind of mechanism. May be security audit can be activated for certain users and then the alert can be passed via CCMS. Under CCMS SAP CCMS Admin Workplace>Security>Logon may be of use. This is purely my opinion. May be it can be even better than this.
    Regards.
    Ruchit.

  • Disabling System.exit() and shutdown calls

    I am trying to splice/hack together something that might stop a System.exit(0) call or perhaps some type of exit call for a Java application. The only thing I have come up with now is making an extension of SecurityException and putting the shutdown code within a try. Here is what I have so far...
    class ExitTrappedException extends SecurityException {
         protected static void forbidSystemExitCall() {
              final SecurityManager securityManager = new SecurityManager() {
                   public void checkPermission( java.security.Permission permission ) {
                        if( "exitVM".equals( permission.getName() ) ) {
                             throw new ExitTrappedException() ;
              System.setSecurityManager( securityManager ) ;
         protected static void enableSystemExitCall() {
              System.setSecurityManager( null ) ;
    }And then utilizing it in the following manner...
    forbidExitCall() ;
        try {
          // Call the "exiting" code here...
        } catch( ExitTrappedException e ) {
        } finally {
          enableExitCall() ;
        }I am not very comfortable setting the SecurityManager to null when re-enabling it to be honest. I am curious if someone might have a different solution to stopping a System.exit(0) call and the windows altf4+ shortcut. Any help would be much appreciated.

         static SecurityManager securityDefault = System.getSecurityManager();
         protected static void forbidSystemExitCall() {
              final SecurityManager securityManager = new SecurityManager() {
                   public void checkPermission( java.security.Permission permission ) {
                        if( "exitVM".equals( permission.getName() ) ) {
                             throw new ExitTrappedException() ;
              System.setSecurityManager( securityManager ) ;
         protected static void enableSystemExitCall() {
              System.setSecurityManager( securityDefault ) ;
    }how bout that?
    Edited by: brillohead on Aug 4, 2008 11:21 AM

  • Catching System.Exit(value) in a unix script

    I am migrating a java application from Windows to Unix, where on the Unix environment it will be run under a batch scheduler.
    I am trying to figure out how to get Unix script 'visibility' to the contents of system.exit().
    At program completion, system.exit is called with either a 0 (all's cool) or -1 (this dog won't hunt).
    I cannot figure out how to get that value communicated back to the invoking script, which currently looks something like:
    cp=<classpath>
    rm -f /staging/*
    $JAVA_HOME/bin/java ........
    rc=$?
    <if 'rc' = 0>
    { :perform this }
    <if 'rc' = -1>
    { :perform this instead }
    Any suggestions?

    rc=$? suggests it's Bourne shell you're running the script with?
    if [ $rc .eq. 0 ]; then
    echo "Bingo!"
    else
    echo "Oh shit..."
    fi
    Better yet, do "man sh" from a unix command prompt -- it gives you the full scoop.

  • System Exit from JAVA Application

    I need to call Oracle Reports from a JAVA application.
    Does anyone have experience in this area?
    One thing that comes to mind is to make a system exit and call the reports from the command line. Is this possible to be done? How?
    Thank you for any help or suggestions.
    Tina.

    the best way to access the oracle database is via jdbc (see http://java.sun.com/products/jdbc/ ). if, however, you specifically need to run some oracle reporting s/w then you could run it as a separate process from your java application using Runtime.exec() (see http://java.sun.com/j2se/1.3/docs/api/java/lang/Runtime.html#exec(java.lang.String) ) which returns a Process object. you can then read its output with the Process object's getInputStream() method (this gives you an InputStream which is the data piped from the standard output stream of the process).
    hth,
    jonesy (sun developer technical support)

  • System.exit(0) problem

    Hi there,
    I open C++ GUI application from Java (using JNI native call). When user clicks "x" and closes GUI application, I'd like to shutdown JVM also. In my code, when user clicks "x", C++ side calls Java method (that contains System.exit(0) call) and this results in the java.exe - Application Error: "The instruction at 0x0 referenced at 0x0. The memory couldn't be read".
    I use Jace to handle JNI calls but this sounds like a pure JNI problem.
    Many thanks in advance.
    Kalle.

    System.exit(0)kills the main thread but you still is in the native function. Return has no a valid address. CallSystem.exit(0) only from JAVA code.

  • System Exit Overriding Busy Loop

    Hi,
    Why would the following code not result in a clean JVM termination when SIGINT is sent? The JVM appears to capture the SIGINT correctly (it hits the shutdown hook), but the System.exit(-1) call cannot seem to override the busy loop and terminate the spawned thread. Is this expected behavior for the VM?
    public class TestSigInt {
         public TestSigInt()
              new Thread()
                   public void run()
                        while(true)
              }.start();
              Runtime.getRuntime().addShutdownHook(new Thread()
                   public void run()
                        System.exit(-1);
         public static void main(String[] args)
              TestSigInt tsi = new TestSigInt();
    }Thanks,
    hhung

    Is this expected behavior for the VM?Yes. See javadoc for System.exit(), that leads to to Runtime.exit():
    If this method is invoked after the virtual machine has begun its shutdown sequence then if shutdown hooks are being run this method will block indefinitely
    So the method blocks (and presumably does nothing, but I admit I'm making up that last bit) if called as part of a shutdown hook.
    the System.exit(-1) call cannot seem to override the busy loop and terminate the spawned threadRegardless of the fact that it's called from a shutdown hook, which previous messages (and the javadoc quoted) already question, there's nothing in the API javadoc that suggests that threads are gracefully "terminated".
    This situation is not different from regular situations when you want to nicely end a thread in an otherwise running Java application: the API does not provide any built-in API (except Thread.stop() and destroy() which are deprecated and which use is strongly discouraged) to stop a running thread.
    See Thread.interrupt() which somehow "kindly" requests interruption of a running thread, but this requires cooperation of the target thread (whose code shoud regularly poll Thread.getCurrentThread().isInterrupted() and terminate accrodingly).
    The usual recommendation to make this more explicit in the code, is that the thread's code regularly checks a business-logic specific boolean, such as:
    class StoppableTask implements Runnable {
        private boolean shouldContinue = true;
        public void run() {
            while (shouldContinue) {
                // do stuff
        public void requestStop() {
            shouldContinue = false;
    public void class StopperThread {
        StoppableTask target;
        public void doOtherStuff() {
            target.requestStop();
    }This requires cooperation form the target thread's code as well, so this is not conceptually different from the interrupt() scheme, it just has different scope (it won't unblock IOs for example).
    Note that I deliberately used Runnable as opposed to Thread, first because it is a recommend practice (but you may know that already and your example was intentionally shorter to get to the point), second to highlight that the specific-solution does not use any built-in java.lang.Thread method.
    Edited by: jduprez on Dec 8, 2009 11:28 AM

  • How stop call to System.exit but allow them to install Securitymanager?

    I have an application that allows you to start a java application from inside it (it then gives you monitoring capabilities). I want this to work with pretty much any desktop application, even those that require their own security manager. However, i don't want their application to be able to shutdown the jvm. How can I do this?
    As far as I can tell, there's no way to allow them to add the securitymanager, "wrapped" by mine is there?
    And I thought of using AccessController.doPriviledgedAction(...) and giving them a context where they can add a security manager but not call system.exit, but then if they do add a security manager, won't it have the final say on system.exit calls?
    Is there a solution here?

    6tr6tr wrote:
    Thanks for the reply!
    Hmmm, the problem with that is I need the users to be able to use my application without access to that app's source code. So they need to be able to run that program (as 3rd party black-boxed code) inside my app and still have this work properly. Is there another way?
    Source code?
    You don't need any source code for what I suggested.
    If a frame/jframe tries to exit on close, I can grab and stop that. my problem is if some random code tries to call system.exit(). Is there any other way to intercept it?
    UPDATE: the only solution i could come up with is to use bytecode engineering + classloading.
    Which I doubt will help if they call it with reflection.
    You could use the bootstrap command line options and replace System with your own version. Add some functionality to how it sets up the security manager and/or make System.exit() do nothing, but provide another name for yourself.

  • How to track exit from the PageFragment Lifecycle

    Hi,
    I have a requirement of keeping track of exit from a pageFragment.
    My structure contains: a TaskFlow which contains a train . This train node contains the page Fragments. Now when i navigate from one PageFrag to another ie. when i exit the currently selected node having a page Fragment, i need to fire a logic.
    I tried using creating a bean which implements RegionController interface which has refreshRegion(RegionContext ) method.I got hold of RegionBinding interface which has only one of the following values: Entry, Execute_Model, Prepare_Model, Refresh_Unknown, Render_Model and Type_executable_region.
    Also in this case i am not exiting the TaskFlow during the navigation.
    My doubt is how do i or can i use RegionController to keep track of exit from the currently rendered PageFragment's  Lifecycle.
    Also , can i use PagePhaseListener to keep track of the PageFragment lifecycle stage. (My understanding is PagePhaseListener is to be used for Jspx not Jsff). Plz do correct me if i am wrong.
    Thanks,
    Prasenjit
    Edited by: user586616 on Aug 31, 2009 3:54 AM
    Edited by: user586616 on Aug 31, 2009 3:57 AM

    Hi Frank,
    I have created a ControllerClass which implements RegionController. I have registered the same as controller class in my pageFragments PageDef.
    So, on navigation from one train node to another. due to post back call to leaving node and freshcall to the arriving node in the train flow. i am able to get the leaving as well approaching node.
    My doubt is can i get similar or better control over the nodes traversed using trainModel or anyother adfinternal controller class? Kindly suggest any better way of getting handle to the navigating train nodes.
    Sample Code which i have implemented:
    public class RegionControllerBean implements RegionController {
    public boolean refreshRegion(RegionContext regionContext) {
    System.out.println("**********************************");
    System.out.println("inside refreshRegion method call");
    String selectedView = ControllerContext.getInstance().getCurrentViewPort().getViewId(); ------> this gives me the handle to the viewId of the curently selected pageFragment
    System.out.println(ControllerContext.getInstance().getCurrentViewPort().getViewId().toString());
    String pageName = selectedView.split("/")[2];
    System.out.println("Current PageName:"+pageName);
    System.out.println("name: "+regionContext.getRegionBinding().getName());
    int refreshFlag = regionContext.getRefreshFlag();
    if(refreshFlag == RegionBinding.PREPARE_MODEL){
    System.out.println("Inside prepare Model phase"); ------> on entering of that node i need to call some logic before prepare_model phase
    if(refreshFlag == RegionBinding.EXECUTE_MODEL){
    System.out.println("Inside execute model phase");
    if(refreshFlag == RegionBinding.RENDER_MODEL){
    System.out.println("Inside render model phase");
    // propagate refresh to inner binding container
    regionContext.getRegionBinding().refresh(refreshFlag);
    return false;
    public boolean validateRegion(RegionContext regionContext) {
    // propagate the validate to inner binding container
    System.out.println("inside validate region method");
    regionContext.getRegionBinding().validate();
    return false;
    thanks,
    Prasenjit

  • The way how field exit gets called??????

    Hi ALL,
    Can any guru tell me how exactally the field exit works.
    Senario- I have created field exit on Data element WERKS_EXT for user validation on plant level for T-code VA01.
    Issue- I don't have proper user details in Dev. system to test this thing, for ulternative what i m doing is; I am running VA01 by putting brake point inside my Include for field exit to check it is getting called or not?
    But the control is not coming to this field exit code and it is creating sales order .
    I have checked, it is ACTIVE and GLOBLE for all screens.
    So, please tell how exactally the field exit works and how i can test this?
    Regards,
    Rahul

    Field exits can only be executed for fields that are directly related tothe dictionary. If the relation is indirect, i.e. via an ABAP declaration ( LIKE ), no field exit can be executed. Field exits cant be debugged.
    For details on field exits, have a look at below link.
    http://www.sap-img.com/abap/field-exits-smod-cmod-questions-and-answers.htm
    http://www.sap-basis-abap.com/sapab014.htm
    Best Regards,
    Vibha
    *Please mark all the helpful answers

Maybe you are looking for

  • Sale Order without Division

    Hi, I have an issue in prodution system, there is a sales order created in 2008 without division (I dont know how the system allowed), this sale order is created with reference to a contract, and the contrct is having division. And now users want to

  • Left Side only work

    I just hooked up my new X-Fi Xtremegamer. I am running Windows x64 Professional and download the latest according drivers from the creative website. I installed drivers and reset and now my headphones are plugged in but only the left side is playing

  • Dv7-3065dx esata port multiplier

    Anyone know if the dv7-3065dx esata port hardware can function as a port multiplier? I want to purchase a Thermaltake BlacX Duet USB 2.0 Portable External Hard Drive but it requires a port multiplier. I have the single slot thermaltake blackx right n

  • Playlist/Ipod Drive problem. Help!

    OK, my brother and i use the same computer to update our ipods. Recently he unplugged his from the computer (without properly ejecting his which i assume is where the problem occured) and immediately plugged mine in. So, now in Itunes and on my Ipod

  • Is there any expected timeline for the next version of XE?

    With all of the changes that have occurred from various aspects impacting Oracle. Is there a next version of XE even planned?