Version 3

    *During the startup phase, I have some code that checks things like environment status, remote resource availability, etc...

    How can I initiate a clean shutdown at that time?*


    You need to write an MBean and in its startService() method you start a non-daemon thread which invokes System.exit(-1).


       // The lifecycle
       protected void startService() throws Exception
"Starting with message=" + message);
          boolean problem = false;
"checking some stuff...");
"oops found some problem!");
          problem = true;
          if(problem) {
              Thread myThread = new Thread() {
                  public void run()
            "Shutting down");




    The source code is attached.