Oracle GlassFish Server 3.0.1 Embedded Server Guide

Starting an Embedded GlassFish Server From an Application

To start an embedded GlassFish Server, invoke the start method of the Server object.

Example 4 Starting an Embedded GlassFish Server

This example shows code for setting the port and starting an embedded GlassFish Server. This example also includes the code from Example 1 for creating Server.Builder and Server objects.

import org.glassfish.api.embedded.*;
    Server.Builder builder = new Server.Builder("test");
    Server server =;