Sun Java System Application Server Enterprise Edition 8.1 2005Q2 Developer's Guide

- Previous: Connecting to the DAS
- Next: Deploying an Archive

## Starting an Application Server

The `startServer()` method demonstrates how to start an Application Server.

##### Example 16–2 Starting an Application Server

    [...]
    startServer( final String serverName )
    {
        final J2EEServer server    = getJ2EEServer( serverName );

        server.start();
    }
    [...]

This method retrieves and starts an application server instance named `server`. The `server` is an instance of the `com.sun.appserv.management.j2see.J2EEServer` interface, and is obtained by calling another method, `getJ2EEServer()`, shown in the following code.

##### Example 16–3 Obtaining a Named J2EE server instance

    [...]
    getJ2EEServer( final String serverName )
    {
        final J2EEDomain j2eeDomain = getDomainRoot().getJ2EEDomain();
        final Map servers = j2eeDomain.getServerMap();
        final J2EEServer server = (J2EEServer)servers.get( serverName );
            if ( server == null )
            {
                throw new IllegalArgumentException( serverName );
            }
        return( server );
    }
    [...]

To obtain a J2EE server instance, the `getJ2EEServer()` method first of all obtains an instance of the `J2EEDomain` interface by calling the `com.sun.appserv.management.base.AMX.getDomainRoot()` and `com.sun.appserv.management.DomainRoot.getJ2EEDomain()` methods. The two methods called establish the following:

- `AMX.getDomainRoot()` obtains the Application Server domain to which `j2eeDomain` belongs.

- `DomainRoot.getJ2EEDomain()` obtains the J2EE domain for `j2eeDomain`.

The `J2EEServer` instance is then started by a call to the `start()` method. The `com.sun.appserv.management.j2ee.StateManageable.start()` method can be used to start any state manageable object.

- Previous: Connecting to the DAS
- Next: Deploying an Archive

- © 2010, Oracle Corporation and/or its affiliates