Terminating JVM

Hi,
Im not sure if what I am thinking can be done, please bear with me...
I have two Java program A and B (I would rather not change the source for B as its a proven app), program A instantiates B through using Runtime.exec(). However program B also starts other processes.
I would like to be able to prematurely terminate the execution of program B from A, and this is where the problem lies. Program B will clean up after itself and terminate prematurely, by using a shutdown hook, so, does anybody know if there is a way to get program B (a java process) to think the System.exit() call has been made, and hence to clean up after itself?
At the moment, the spawned processed carry on autonomously in the back ground!!
I would be grateful for any input.
Steven Franklin

Use Process.destroy();. It kills the subprocess represented by that process object.

Similar Messages

  • Posiibility for terminating jvm inside try block so that finally block wont

    posiibility for terminating jvm inside try block so that finally block wont execute at all ?
    But in that case what will happen?
    Is it safe for any practical situation ?
    Threads: t.stop()
    JVM : System.exit()
    which one can really help and where?

    What if security Manager comes into picture?
    class ExitCatchingSecurityManager extends SecurityManager
    public void checkExit(int status)
    Process.terminateProcessWithThreadGroup(getThreadGroup());
    throw new SecurityException();
    What if an application calls System.exit()?
    We still have one big hole in our multiprocess library. If any application calls System.exit(), the JVM terminates, and all the pseudo-processes will be destroyed with no warning. Fortunately, Java's design once again comes to our aid. Any call to System.exit() is first checked by the SecurityManager to see if the application has permission to terminate the JVM. We can install our own SecurityManager to catch the System.exit() call, disallow it, and terminate the pseudo-process instead. The SecurityManager is actually quite simple to define:
    class ExitCatchingSecurityManager extends SecurityManager
    public void checkExit(int status)
    Process.terminateProcessWithThreadGroup(getThreadGroup());
    throw new SecurityException();
    In addition, the SecurityManager should define all other checks so that they do not block pseudo-processes from running. A simple null call for all check* methods will work. We install our own SecurityManager by calling System.setSecurityManager(), i.e., by adding the following line near the startup of the multiprocess library:
    System.setSecurityManager(new ExitCatchingSecurityManager());
    The Process.terminateProcessWithThreadGroup() method is simple to define, by holding a collection of Process objects in the Process class, searching the collection to find the Process with the identical ThreadGroup, then terminating that Process.

  • How to trap (interrupt) signal from JVM

    How to capture (interrupt) signal from JVM in case of JVM termination due to Error/RuntimeException in shell script (Unix/Linux OS). Is it possible?
    I am executing an java class from shell script. In cetain condition it throws RuntinmeException.
    I want to capture the signal from terminating JVM in case of the RuntimeException.
    How to acheive this ? Can any one solve this problem ?

    Hi
    Using the POSIX signal java program , We can trap the JVM signals.
    Addition info
    Use sun.misc.SignalHandler - interface
    and MEthod sun.misc.Signal.handle( new sun.misc.Signal(signalName), this );

  • System.exit(int) - Just For Fun

    import java.applet.*;
    public class BrowserKill extends Applet {
      public void init() {
        System.exit( 0 );
    }Terminate JVM while the browser is trying to contact JVM.
    Wow ... I've tried this code in IE 6.0 ... It crashed my browser ...
    What do you think ?
    You can try this code in JSP/Servlet ...
    I'm sure that the server will be crashed. (Because of terminating JVM)

    Wow ... I've tried this code in IE 6.0 ... It crashed my browser ...
    What do you think ?Serves you right for using such a rubbish browser. The security manager should have trapped the call and thrown a SecurityException, killing the applet but not the VM.

  • JVM termination with standalone oc4j

    Hi,
    We have several (around 15) standalone oc4j instances running on a Sun machine, the details are as follows:
    Machine: SunFire V1280 with 8 processors (sun4u sparc) and 24 GB RAM
    OS: SunOS 5.9 Generic_117171-02
    oc4j version: 9.0.4.0.0
    There is also a 10g installation on this machine.
    We are finding that quite regularly one or more of the oc4j instances shuts down without warning. the only information in the log files (jms.log, rmi.log etc) is a "Stopped (JVM termination)" message. I cannot find any other logs on the machine which can help me with this error.
    I am after one of two things:
    1. Potential reasons for this happening (preferably with solutions!)
    2. A possible for a log file created by the JVM detailing why it is terminating.
    Can anyone help?
    Thanks

    http://blogs.oracle.com/shay/2005/10/24#a55

  • Workshop JVM terminated

    I wanted to try out the new 9.2 stuff so I downloaded the 9.2 portal and started going through the "Getting Started With Weblogic Portal" tutorial.
    Everytime I try to change to the portal perspective the workshop dies. I get the Workshop4WP window that says "JVM terminated. Exit code=1" then lists the command line that was run to start the thing.
    Am I the only one to have this problem? I don't see any other posts so I am assuming that I am.
    I have all of the 8.2 tools installed as well as the latest version(3.2) of eclipse and they still work fine.
    I can dupllicate this every time by trying to switch to the portal perspective and none of the other perspectives have this problem.
    Stay out of the portal persective you say... this would probably work if the ide didn't try to switch itself fairly frequently.
    I wonder if it is a particular view that it doesn't like or if it is the particular JVM (150_04 jre that came with one of the bea downloads).
    Any Ideas?
    I just tried to look at the Weblogic Portal in the preferences and get the same thing.
    Edited by stacybro at 12/22/2006 11:28 AM

    Go to <BEA Installed Directory>\workshopXX\workshop4WP\
    Edit workshop4WP.ini, reduce the -Xmx value to something less but more than -Xms.
    Go to taskManager and make sure no process with name workshop4WP.exe is running. If it is running, kill it!
    Now try starting Workshop again.
    Note:
    Make sure you take a backup of workshop4WP.ini before editing the file, just to revert back, in case something bad happens.
    Regards,
    Sandeep@fTf

  • "JVM terminated" error

    Downloaded and installed the newest release of beta 3.2.
    Running in XP. Started working through the tutorial; clicked on the
    Design View tab, and it shuts down FlexBuilder and pops up a long
    JVM terminated message.
    I see others posted this problem earlier in the summer, but
    haven't seen a resolution.

    Hi there,
    We'd really like to take a look at this but we need your help
    since we aren't reproducing this condition. Can you give us a bit
    more information and if you have the time
    file a bug? Is it simply
    that you click on design view? Can you try to reproduce using a new
    workspace?
    Choose File > Switch workspace
    > Other, type in a new workspace location and hit ok.
    Create a new project and try to
    reproduce the issue
    This may solve the problem in which case
    Choose File > Import > Other
    > General > Existing projects into workspace
    Browse to the location of your
    existing projects (usually documents/flex builder 3 or my documents
    \flex builder 3) and hit OK.
    select the appropriate projects and
    import them.
    Either way, I urge you to file a bug in our public facing bug
    system. and post the bug number back to this thread. It is very
    hard for us to address an issue when we can reproduce it so that is
    where we need your help.
    Thanks
    -Larry
    Flex Builder Team
    http://bugs.adobe.com/flex/

  • Netweaver Developer Studio 7.3 "JVM terminated exit code = -1"

    Hello,
    the developer studio can not be started and the error which is shown is "jvm terminated. exit code = -1"
    My system is windows7, I am using oracle java 1.6, NWDS  (7.3 SP01).
    This is my .ini file:
    -vm
    C:\Program Files\Java\jdk1.6.0_21\bin\
    -startup
    plugins/org.eclipse.equinox.launcher_1.0.201.R35x_v20090715.jar
    -nl
    en
    -vmargs
    -Xmx512m
    -Xms128m
    -XX:PermSize=32m
    -XX:MaxPermSize=256m
    -Dfile.encoding=UTF-8
    -XX:+HeapDumpOnOutOfMemoryError
    -Dosgi.requiredJavaVersion=1.6
    Very strangely, I actually succedeed to run the NWDS once when saving the .ini as unicode. But then I could not update the studio with new features, I got "Unsupported major.minor version 49.0u2033. I suspect that actually the studio could not be started properly with java 1.6, but with java 1.4, which was also installed on my system. After deinstalling java 1.4.2, the studio can not be started again.
    Please, help me to resolve it.

    I resolved the problem. The NWDS required 32-bit JVM and I used 64-bit.
    The interesting thing is that java -version says:
    Error loading: C:\Program Files (x86)\Java\jre6\bin\msvcr71.dll
    Error occurred during initialization of VM
    Unable to load native library: Can't load IA 32-bit .dll on a AMD 64-bit platform

  • System.exit(0) - Avoid JVM termination

    Hi,
    Is there any possibility to avoid JVM termination when we use system.exit(0).
    I have created my own SecurityManager.
    public class MySecurityManager extends SecurityManager {.....}, and I can able to get S.O.P at public void checkPermission(final Permission permission) {..} and public void checkExit(int status) {..} in SecurityManager , My code in main() is
    MySecurityManager mySM = new MySecurityManager();
              System.setSecurityManager(mySM);
    System.out.println("Before......");
    System.exit(0);
    System.out.println("After......");
    i cant able to get SOP "After.....",
    Is there any possibility to raise exceptions when i introduce exit(0) in my java file.....? or Is there any possibility to avoid JAVA termination when i use System.exit(0).
    Thankx in Advance

    uh, System.exit is defined as the command to
    terminate the JVM. You can avoid that by not calling
    System.exit...Or do just what the OP tried to do.
    class Test {
         public static void main(String args[]) throws Exception {
              System.setSecurityManager(new ExitHandlingSecurityManager());
              System.out.println("Before");
              try {
                   System.exit(1);
              } catch (SecurityException e) {
                   System.err.println("Couldn't exit the VM: " + e.getMessage());
              System.out.println("After");
    class ExitHandlingSecurityManager extends SecurityManager {
         @Override
         public void checkExit(int arg0) {
              throw new SecurityException("You aren't allowed to terminate VM");
    }Prints:
    Before
    Couldn't exit the VM You aren't allowed to terminate VM
    After
    Kaj

  • Jvm not terminating in Solaris 8

    We are running Weblogic 7.0 sp1 on Solaris 8.
    When we attempt to shutdown managed servers or admin server with a graceful
    shutdown the java process is still in the process table?? We didnt
    notice this
    with Weblogic 7.0.
    Also if you do a force shutdown then the jave process terminates
    Any ideas

    This is a known issue. Contact [email protected] and reference CR087180.
    For now use kill -9 or weblogic.Admin SHUTDOWN to shutdown the managed
    server.
    Larry Presswood wrote:
    As a note this happens only in the following situation
    We have an admin server and two managed servers.
    When we shutdown the manged server but not the admin server their jvms
    ie managed server jvms dont terminate nor do their scripts. We are not
    using
    node manager. Now if you shutdown the admin server then all jvms will
    terminate
    So it appears as though the jvms in the managed servers are waiting on
    something
    from the admin server prior to terminating??
    Larry Presswood wrote:
    We are running Weblogic 7.0 sp1 on Solaris 8.
    When we attempt to shutdown managed servers or admin server with a
    graceful
    shutdown the java process is still in the process table?? We didnt
    notice this
    with Weblogic 7.0.
    Also if you do a force shutdown then the jave process terminates
    Any ideas
    Rajesh Mirchandani
    Developer Relations Engineer
    BEA Support

  • Nw deveoper studio won't start: JVM terminated. Error code=1

    Hi there,
    I have been using netweaver dev studio without problems. Then from one second to another, after closing the application and reopening it refused to open and gives this error message:
    JVM terminated. Error code=1
    C:\Program Files\j2sdk1.4.2_08\bin\javaw.exe
    -Xmx512m
    -Xms128m
    -XX:PermSize=32m
    -XX:MaxPermSize=128m
    -DallUserDir='C:\Documents and Settings\All Users\Application Data'
    -cp C:\Program Files\SAP\JDT\eclipse\SapStartup.jar com.sap.ide.eclipse.startup.Main
    -os win32
    -ws win32
    -arch x86
    -feature com.sap.java.ide
    -showsplash C:\Program Files\SAP\JDT\eclipse\SapIde.exe -showsplash 600
    Any ideas?
    Cheers,
    faB
    edit: fixed it. was a memory problem.

    Hi Expert,
    I have been working on NWDS-7.0.09 & J2sdk1.2.4_12 , and <b>now I unable to open it and gives following errors messages.[</b>i]But when I tried with full window Admin Access ( this  access has given by Admin for a day) then it is working fine.but it doesn't solve my problem</i> Could you tell me what is the problem.
    How to rectify it.
    <b>JVM terminated. Error code=22
    C:\j2sdk1.4.2_12\bin\javaw.exe
    -Xmx512m
    -Xms128m
    -XX:PermSize=32m
    -XX:MaxPermSize=128m
    -DallUserDir='C:\Documents and Settings\All Users\Application Data'
    -cp C:\Program Files\SAP\IDE\IDE70\eclipse\SapStartup.jar com.sap.ide.eclipse.startup.Main
    -os win32
    -ws win32
    -arch x86
    -feature com.sap.java.ide
    -showsplash C:\Program Files\SAP\IDE\IDE70\eclipse\SapIde.exe -showsplash 600</b>
    Thanks
    Roohi

  • JVM terminated when opening a process

    I applied the add-on to LC Workbench 9.0.0.1 on Windows 7.
    After launching Workbench as administrator, I got "JVM terminated" error when I open (or create) a process.
    "JVM terminated. Exit code = -1073740940 ....." - error dialog.
    Why is that?
    Thx,
    K7

    This is the error log when JVM termination occurs.
    !ENTRY com.adobe.ide.singlesignon 1 1 2010-07-14 17:42:08.511
    !MESSAGE User 'administrator' logged in to server 'k7es2mcry' (hostname: 'k7es2mcry')
    !SESSION 2010-07-14 17:42:33.835 -----------------------------------------------
    eclipse.buildId=unknown
    java.version=1.6.0_14
    java.vendor=Sun Microsystems Inc.
    BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=ja_JP
    Framework arguments:  #Product Runtime Configuration File
    Command-line arguments:  -os win32 -ws win32 -arch x86 #Product Runtime Configuration File
    !ENTRY org.eclipse.core.resources 2 10035 2010-07-14 17:42:35.484
    !MESSAGE The workspace exited with unsaved changes in the previous session; refreshing workspace to recover changes.
    !ENTRY com.adobe.ide.singlesignon 1 1 2010-07-14 17:42:36.427
    !MESSAGE LiveCycle Workbench ES version '9.1.0.v201006272231'
    !ENTRY org.eclipse.equinox.p2.ui.sdk 2 0 2010-07-14 17:42:39.870
    !MESSAGE Could not locate the running profile instance. The eclipse.p2.data.area and eclipse.p2.profile properties may not be set correctly in this application's config.ini file.

  • JVM terminated. when trying to Acess Catalog manager

    Unable to access "Catalog Manager" . I get JVM terminated error. Error code =1
    and error message follows..
    How do i make catalog manager make work normal.
    Edited by: user624475 on Jun 5, 2010 9:47 PM
    Full Error:
    JVM terminated. Exit code=1
    C:\Program Files\Java\jdk1.5.0_19\bin\javaw.exe
    -Xmx1024M
    -Djava.library.path=C:\OracleBI\web\bin
    -Dosgi.clean=true
    -Declipse.noRegistryCache=true
    -jar C:\OracleBI\web\catalogmanager\startup.jar
    -os win32
    -ws win32
    -arch x86
    -launcher C:\OracleBI\web\catalogmanager\catalogmanager.exe
    -name Catalogmanager
    -showsplash 600
    -exitdata 84_a8
    -vm C:\Program Files\Java\jdk1.5.0_19\bin\javaw.exe
    -vmargs
    -Xmx1024M
    -Djava.library.path=C:\OracleBI\web\bin
    -Dosgi.clean=true
    -Declipse.noRegistryCache=true
    -jar C:\OracleBI\web\catalogmanager\startup.jar
    Edited by: user624475 on Jun 5, 2010 9:47 PM

    restart your system
    i hope you are doing it on local machine
    i encountered the same and was cleared when i restarted the system
    and to make it better, clear tmp files in c drive
    thanks
    Raki

  • JVM terminated sometime

    Dear all,
    I got this error promot sometime.  After that, all my applications closed and my coding done before had not been saved.  Do you have any idea for this?  Thank you very much!
    JVM terminated. Exit code=1
    C:\Program Files\Java\jre1.6.0_03\bin\javaw.exe
    -Xmx512m
    -Xms128m
    -XX:PermSize=32m
    -XX:MaxPermSize=128m
    -DallUserDire='d:\Documents and Settings\All Users\Application Data'
    -cp C:\Program Files\SAP\IDE\IDE70\eclipse\SapStartup.jar com.sap.ide.eclipse.startup.Main
    -os win32
    -ws win32
    -arch x86
    -feature com.sap.java.ide
    -showsplash C:\Program Files\SAP\IDE\IDE70\eclipse\SapIde.exe -showsplash 600
    Best regards,
    Anne

    hi
    This problem may be because of Memory problem
    By Increasing the JVM heap memory size should solve up the problem.
    once check this sap note also for memory problems..
    759669
    Regards
    sowmya.

  • Maven - ERROR: Maven JVM terminated unexpectedly with exit code 0

    Hi All,
    I have written pom.xml for auto deployment process between hudson and deployment servers.
    The script which i return its working perfectly i can see the application in web logic server. The application has been deployed in the web logic server. No issues that.
    All the remaining task is also very well working in the servers but the build is failing as **failed** by saying the below error in hudson
    [ServerConnectionImpl.close():332] : Closing DM connection
    [ServerConnectionImpl.close():352] : Unregistered all listeners
    [ServerConnectionImpl.closeJMX():372] : Closed JMX connection
    [ServerConnectionImpl.closeJMX():384] : Closed Runtime JMX connection
    [ServerConnectionImpl.closeJMX():396] : Closed Edit JMX connection
    **ERROR: Maven JVM terminated unexpectedly with exit code 0**
    Sending e-mails to: [email protected]
    Finished: FAILURE
    I dont why like this happening in the maven.
    Here is my maven opts set in Hudson server.
    Maven_OPTS : -Xms256m -Xmx1024m -XX:MaxPermSize=512m
    kindly help me to resolve this issue. Thanks in advance.
    Regards,
    Rocky.

    Hi Sir,
    Please try the following items:
    1. if ther is anti-virus installed , please uninstall it temporarily
    2. run  " sfc /scannow "
    3. keep windows up-to-date
    4. if you updated some hardware driver please roll it back
    5. if the issue persists , please use windows installation media to perform inplace-upgrade for the system
    Also please refer to reinstall C++ runtime within the similar thread:
    https://social.technet.microsoft.com/Forums/windows/en-US/bf69eeff-24c4-499f-b280-b6a3098f4f9f/problem-with-msvcrtdll-version-70760117744?forum=w7itprogeneral
    Best Regards,
    Elton Ji
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact [email protected] .

Maybe you are looking for

  • 6110 Navigator - doesn't see other BT devices

    This is really starting to give me the sh*ts. I cannot see any other bluetooth devices with my 6110 Navigator, even when the other device is 5cm away. I recently purchased a "Pilot-mini" BT hands-free (think similar to Blue Ant "Lite") and my 6110 ca

  • Problem with JSC2 field guide "objectListDataProvider" example

    Is there any chance that the example objectListDataProvider example (chapter 8.3, page 360) in the Java Studio Creator Field Guide will be updated with the proper instructions? The example in the book isn't working as the "objectListDataProvider" lis

  • How to use the Forte C++ (SunWorkshop)

    Hello! I want to compile the Wine (Windows Emulator) for Solaris 9 (x86). One way is that I install gcc 3.2, and the other is to use the FORTE C++ compiler provided by Sun Microsystems. Now, I have downloaded the gcc-3.2 source code from the sunfreew

  • Why have inner classes

    Well I can understand the purpose of inner classes in multithreaded applications or where you need a continous monitoring, but I have always been wondering why use an inner application in a normal application. Any ideas?

  • Window position problem

    Hi everyone, I am having problems with window position. If my portal is set to english language, there are no problem. If my portal is set to hebrew language, I have troubles with position of windows. Some windows are moved to left, some are moved to