Get started with GlassFish

This guide will lead you to install GlassFish, start it and run your applications with it.

Introduction

Eclipse Glassfish is a server for developing and running enterprise and web applications based on Jakarta EE and MicroProfile. GlassFish is developed through the opensource community project at the Eclipse Foundation. The Eclipse GlassFish project provides a structured process for developing the GlassFish platform faster, while maintaining the most important feature of Jakarta EE: compatibility with older versions.

This guide will get you started with GlassFish, from downloading GlassFish to running an application on it.

Requirements

Before installation, you should make sure that you meet the following minimum requirements

  • Required JDK Versions : Eclipse GlassFish Release 7 requires Java 11 or newer. It’s tested on Java 17 and Java 21.
  • Required Disk Space : The download sizes for Eclipse GlassFish 7 vary depending on the package you choose. The following are the approximate sizes of the ZIP packages for the Full and Web profiles:
    • Full *.zip: 114 MB (136 MB unzipped)
    • Web *.zip: 64.9 MB (82.9 MB unzipped) The installation sizes will vary depending on your configuration, but the approximate amount of disk space used by Eclipse GlassFish 7 is as follows:
    • Full: 138 MB
    • Web: 84.4 MB
  • Required Free Ports : You must have sixteen unused ports available for the ports Eclipse GlassFish uses. The installation program automatically detects ports that are in use and suggests currently unused ports for the default settings. The initial default port assignments are listed in the following table. If these default port numbers are in use, the installation program assigns a randomly selected port number from the dynamic port range. The selected port number might not be the next available port number.
    • You can find the list of default port assignments in GlassFish in the Configuration Reference section at the end of this guide.

In some situations, such as when multiple domains are running on a single host, port conflicts can arise in the auto-generated ports used by Message Queue and the GMS. To avoid these conflicts, you can configure the JMS host and the GMS to use specific ports.

Download

The latest version of Eclipse Glassfish is availaible for download on the Glassfish website.

Installation

Installation files for Eclipse GlassFish are available for download from the Eclipse GlassFish Downloads page.

When downloading GlassFish, you can choose from two variants:

  • Eclipse GlassFish, Jakarta EE Platform – this variant contains all the features of GlassFish Server, including full Jakarta EE Platform, and supported MicroProfile APIs
  • Eclipse GlassFish, Jakarta EE Web Profile – this variant of GlassFish Server contains Jakarta EE Web Profile, a subset of Jakarta EE Platform. It doesn’t contain MicroProfile APIs. It contains all other features of the GlassFish Server

The download page also offers the same two variants for Eclipse GlassFish Embedded, which is a version of GlassFish that can be started and configured from a Java application using Java APIs. GlassFish Embedded provides the same features as GlassFish Server, except some enterprise features like clustering and administration console. It’s used differently than GlassFish Server. This guide only describes how to use the GlassFish server, it doesn’t explain how to use GlassFish Embedded.

Installing Eclipse GlassFish Using the ZIP File

  1. After download the ZIP file, change to the directory where you downloaded the ZIP file.
  2. Unzip the file.
  • Mac OS X, Linux, and Unix-like systems:
    • > unzip zip-file-name
    • zip-file-name is the name of the file that you downloaded. For example: glassfish-7.0.13.zip
  • Windows systems:
    • Unzip using your favorite file compression utility. Eclipse GlassFish 7 is extracted into a new glassfish7 directory under your current directory. This glassfish7 directory is referred to throughout the Eclipse GlassFish documentation set as as-install-parent.

You can now continue to using GlassFish with your favorite Java IDE:

For using GlassFish without an IDE, continue with the next sections in this guide.

Starting GlassFish and Configuration

Starting and Stopping the Server

When you install Eclipse GlassFish, it contains the default configuration section (called domain in GlassFish) with the name name domain1. The following procedures describe how to start and stop GlassFish with this domain1 configuration when it is the only domain configured.

Start GlassFish with the Default Domain

Run GlassFish in foreground, with the startserv command and the default domain1 configuration:

as-install/bin/startserv

You can also run GlassFish in the background, with the asadmin start-domain command:

as-install/bin/asadmin start-domain

The command starts the server with the default domain configuration, domain1.

Stop GlassFish

Run the stopserv command or asadmin stop-domain command without an arguments:

as-install/bin/stopserv 

The command stops the server with the default domain configuration, domain1.

In older GlassFish versions, the stopserv command is present in glassfish/bin directory only: as-install/glassfish/bin/stopserv. You can also stop the server with as-install/bin/asadmin stop-domain.

To determine whether the server is running (with the domain1 configuration), use the asadmin list-domains command:

as-install/bin/asadmin list-domains

Starting the Administration Console

The Eclipse GlassFish Administration Console provides a browser interface for configuring, administering, and monitoring GlassFish. When you have GlassFish server running, you can access it in the following way:

  • Type the Admin Console URL in your browser. Admin Console is exposed on port 4848 by default. The default URL for the Administration Console on the local host is as follows: http://localhost:4848.

Running applications

Deploying Applications

The process of configuring and enabling applications to run within the Eclipse GlassFish framework is referred to as deployment. This section explains how to deploy (run), list, and undeploy (stop) applications. The procedures in this section use the hello.war sample application, that you can download from here:

GlassFish server must be running before you deploy the sample application.

Using command line

To deploy the application using command line, follow these instructions:

  1. Run the asadmin deploy command. The general form for the command is as follows:
    as-install/bin/asadmin deploy war-name
    • To deploy the hello.war sample, the command is as follows:
      as-install/bin/asadmin deploy sample-dir/hello.war2
  2. Access the hello application by typing the following URL in your browser: http://localhost:8080/hello
  3. The application’s start page is displayed, and you are prompted to type your name:
    Hi, my name is Duke. What's yours?
  4. Type your name and click Submit. The application displays a customized response, giving you a personal Hello.
  5. To List Deployed Applications From the Command Line, run the asadmin list-applications command:
    as-install/bin/asadmin list-applications

To Undeploy the Sample Application From the Command Line:

  1. Run the asadmin undeploy command. The general form for the command is as follows:
    as-install/bin/asadmin undeploy application-name
    • For the sample application hello.war, use the text “hello”, not the file name “hello.war”. The name of the application is derived from the file name but doesn’t contain the “war” extension. You can see the name of the application in the output of the list-applications command. For the hello.war example application, the command is as follows:
      as-install/bin/asadmin undeploy hello

Using the Administration Console

To deploy the application using the Administration Console, follow below instructions:

  1. Launch the Administration Console by typing the following URL in your browser: http://localhost:4848
  2. Click the Applications node in the tree on the left.
  1. Click the Deploy button.
  1. Select “Packaged File to be Uploaded to the Server”, and click Browse.
  2. Navigate to the location in which you saved the hello.war sample, select the file, and click Open. You are returned to the Deploy Applications or Modules page
  3. Specify “hello” in the “Context Root” field – this specifies that the application will be available at http://localhost:8080/hello
  1. Accept the other default settings, and click OK. You are returned to the Applications page.
  2. In the row for the “hello” application, click the “Launch” link in the “Action” column to access the application. This opens a new window with all the links where the application is available. Click one of the links to access the application. The application will be available at http://localhost:8080/hello/, although the links in the Administration console may contain name of your computer instead of “localhost”.

To Undeploy the Sample Application by Using the Administration Console:

  • Launch the Administration Console by typing the following URL in your browser: http://localhost:4848
  • Click the “Applications” node in the tree on the left.
  • Select the check box next to the hello sample application.
  • Remove or disable the application.
    • To remove the application, click the Undeploy button. This will stop the application and remove it from the server completely
    • To disable the application, click the Disable button. This will stop the application. It will stay in the server and it will be possible to enable (start) it again

Deploying and Undeploying Automatically from the filesystem

Eclipse GlassFish enables you to performing the following deployment-related tasks automatically, just by copying or deleting the application file.

You can deploy applications automatically by placing them in the domain-dir/autodeploy directory, where domain-dir is the directory of the domain for which you want to configure automatic deployment. For this example, use the default domain, domain1, in the default directory which is as-install/domains: as-install/domains/domain1/autodeploy

To deploy the sample application on Linux, Mac OS X or other Unix-like systems, type this command:
cp sample-dir/hello.war as-install/domains/domain-dir/autodeploy

On Windows systems, type this command:
copy sample-dir\hello.war as-install\domains\domain-dir\autodeploy

GlassFish automatically discovers and deploys the application. The default URL for the application is as follows: http://localhost:8080/hello/. This time, you don’t configure the context root of the URL, it is derived from the name of the WAR file or it is defined in a configuration file inside the WAR file.

To Undeploy the Sample Application Automatically

  • Change to the autodeploy directory: cd as-install/domains/domain1/autodeploy
  • Delete the sample application’s WAR file to undeploy and remove the application.
    • On Linux, Mac OS X, or other Unix-like systems, type this command:
      rm hello.war
    • On Windows systems, type this command:
      del hello.war

GlassFish configuration reference

Default port assignments

The following table lists all the network listeners opened by GlassFish and their default port numbers:

Default PortsListener description
4848Administration Console
(also for Admin and Monitoring REST interfaces)
8080HTTP
8181HTTPS
8686JMX service
3700IIOP
3820IIOP/SSL
3920IIOP/SSL with mutual authentication
22SSH port
9009Java debugger
7676JMS provider
Auto-generated from the operating system’s dynamic port rangeMessage Queue TCP port
Auto-generated from the operating system’s dynamic port rangeMessage Queue Admin port
9090GMS TCP start port
9200GMS TCP end port
Auto-generated between GMS TCP start and end portsGMS listener port
Auto generated between 2048 and 49151GMS multicast port
Default Port Assignments in GlassFish

Default Paths and File Names

The following table describes the default paths and file names that are used in this guide.

PlaceholderDescriptionDefault Value
as-installRepresents the base installation directory for Eclipse GlassFish.Installations on Linux, Mac OS, and Unix-like systems: user’s-home-directory/glassfish7/glassfish.
Installations on Windows : SystemDrive:\glassfish7\glassfish
as-install-parentRepresents the parent of the base installation directory for Eclipse GlassFish.Installations on Linux, Mac OS, and Unix-like systems:: user’s-home-directory/glassfish7. Installations on Windows: SystemDrive:\glassfish7
domain-root-dirRepresents the directory in which a domain is created by default.as-install/domains/
domain-dirRepresents the directory in which a domain’s configuration is stored.domain-root-dir/<domain-name>
instance-dirRepresents the directory for a server instance.domain-dir/<instance-name>
Default Paths and File Names in GlassFish

Default Administration Values

The following table lists default administration values for Eclipse GlassFish:

DescriptionDefault Value or Location
Domain namedomain1
Master passwordchangeit
asadmin command-line utilityas-install/bin/asadmin
Configuration filesdomain-dir/config
Log filesdomain-dir/logs
Default Administration Values in GlassFish

Scroll to Top