Getting Started with GlassFish: A Complete Beginner’s Guide Java Enterprise Edition (Jakarta EE) powers some of the largest, most scalable applications in the world. To run these applications, you need a robust application server. Eclipse GlassFish is one of the most popular, open-source, production-ready options available today.
Whether you are a student learning enterprise Java or a developer deploying your first web app, this guide will take you from installation to your very first running application. What is GlassFish?
GlassFish is a full-featured Jakarta EE application server. It serves as a container that manages enterprise Java components like Servlets, JavaServer Faces (JSF), and Enterprise JavaBeans (EJB). Key Features
Full Specification Support: GlassFish supports the complete Jakarta EE profile, giving you access to all enterprise Java APIs.
Admin Console: It includes a user-friendly, web-based dashboard to manage your server configuration easily.
Lightweight and Fast: Despite its power, it starts up quickly and has a small footprint during development.
Open Source: Maintained by the Eclipse Foundation, it benefits from a strong, active community. Step 1: Prerequisites
Before installing GlassFish, you must install the Java Development Kit (JDK).
Download and install JDK 11 or JDK 17 (depending on the GlassFish version you choose). Set your JAVA_HOME environment variable.
Verify the installation by running this command in your terminal: java -version Use code with caution. Step 2: Download and Install GlassFish
GlassFish does not use a traditional installer wizard. Instead, it is distributed as a simple ZIP archive. Visit the official Eclipse GlassFish downloads page. Download the latest stable Full Platform zip file.
Extract the downloaded ZIP file to a preferred directory on your computer (e.g., C:\glassfish or /opt/glassfish). Step 3: Starting and Stopping the Server
GlassFish relies on a command-line tool named asadmin (Application Server Administration) located inside the glassfish/bin directory. Start the Server
Open your terminal, navigate to the glassfish/bin directory, and run: ./asadmin start-domain Use code with caution. (On Windows, use asadmin.bat start-domain)
You will see a success message indicating that domain1 is running. Verify It Works
Open your web browser and navigate to http://localhost:8080. You should see the default GlassFish welcome page. Stop the Server
To shut down the server, run the following command from the bin folder: ./asadmin stop-domain Use code with caution. Step 4: Exploring the Admin Console
One of GlassFish’s best beginner features is its Graphical User Interface (GUI) for server management. Ensure your server is running. Open your browser and go to http://localhost:4848.
You will be greeted by the GlassFish Administration Console.
From this dashboard, you can monitor server health, configure database connection pools, manage security realms, and deploy applications without touching the command line. Step 5: Deploying Your First Application
Let’s deploy a standard Java web application archive (a .war file). Method 1: Using the Admin Console Log into the Admin Console (http://localhost:4848). Click on Applications in the left-hand menu. Click the Deploy button.
Select Packaged File to be Uploaded to the Server and choose your .war file. Click OK. Your app is now live! Method 2: Autodeploy (The Easiest Way)
GlassFish includes a “hot-deployment” folder that automatically deploys apps when files are moved into it.
Locate the directory: glassfish/glassfish/domains/domain1/autodeploy/ Drop your compiled .war file directly into this folder.
GlassFish will automatically detect, extract, and run the application within seconds. Next Steps
Now that your server is up and running, you are ready to build enterprise-grade applications. Try integrating an Integrated Development Environment (IDE) like Apache NetBeans, Eclipse IDE, or IntelliJ IDEA with your GlassFish server to compile and deploy your code automatically with a single click. To help you get your project off the ground, tell me: What version of Java / JDK are you using?
Leave a Reply