Terminate the currently running java code

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • abhishekbrave
    New Member
    • Dec 2007
    • 79

    Terminate the currently running java code

    I want to exit from a java code after the execution of the code it contains.
    When I am trying System.exit() at the end of the program the System.exit() shuting down the complete JVM. I just want to exit from the current program.
    Which comman I can use to exit from the program.
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Originally posted by abhishekbrave
    I want to exit from a java code after the execution of the code it contains.
    When I am trying System.exit() at the end of the program the System.exit() shuting down the complete JVM. I just want to exit from the current program.
    Which comman I can use to exit from the program.
    If you want to stop your entire program (i.e. all non-daemon threads are stopped)
    and your JVM sits there, just idle, why do you want it to stay alive?

    kind regards,

    Jos

    Comment

    • abhishekbrave
      New Member
      • Dec 2007
      • 79

      #3
      Originally posted by JosAH
      If you want to stop your entire program (i.e. all non-daemon threads are stopped)
      and your JVM sits there, just idle, why do you want it to stay alive?

      kind regards,

      Jos
      Actaully the code is written using API's of a tool(server) and it is running with that tool, is i stop the entire JVM then the entire server will stop running.

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        Originally posted by abhishekbrave
        Actaully the code is written using API's of a tool(server) and it is running with that tool, is i stop the entire JVM then the entire server will stop running.
        I find it a bit strange that your code (a client) and a server run in a single process.
        Isn't there any way to simply login or register or whatever to that server?

        kind regards,

        Jos

        Comment

        • abhishekbrave
          New Member
          • Dec 2007
          • 79

          #5
          Originally posted by JosAH
          I find it a bit strange that your code (a client) and a server run in a single process.
          Isn't there any way to simply login or register or whatever to that server?

          kind regards,

          Jos
          I have written a custom java class code using the api of the tool, and mentioned the class path of the java class in the handler provided by the server. The java class is configured to run during a particular event occurs in the tool.But the code in java class is executing more then once coz of some reasons in the tool so i want to stop the code only after once it is executed.
          I have used System.exit() but it stops the whole server. So i am looking for some command in java code which let me exit from the java code

          Comment

          • venukb
            New Member
            • Jun 2008
            • 3

            #6
            System.exit is just a convenient method for calling Runtime.exit() method
            And as the javadoc for Runtime exit says, it terminates the currently running Java virtual machine by initiating its shutdown sequence.

            If you want to exit from the method, why not use a return ?

            Comment

            Working...