GlassFish 7 in Visual Studio Code
To set up GlassFish Server in Visual Studio Code, follow these steps:
Setup Java support in Visual Studio Code
- Set up Java SE 11, or Java SE 17, Visual Studio Code
- Make sure JAVA_HOME environment variable is correctly and points to your Java installations
- You will also need to set up the Extension Pack for Java in Visual Studio Code
- If you use Gradle for building your project, you’ll also need the Gradle for Java extension.
- For more details about installing Java support in VS Code, follow the Java build tools in VS Code guide.
Add GlassFish Server to VS Code
- In VS Code, set up the Community Server Connectors extension, which provides a plugin for GlassFish
- Then open the Explorer sidebar
- Click on the SERVERS section
- Right-click on Community Server Connector, and select the Create New Server… option
- Then either choose to download and install GlassFish 7, or to use an existing GlassFish Server installation (download GlassFish here)
Run your application with GlassFish
- In Visual Studio Code, open the directory that contains your project. Visual Studio Code will do the rest for you, it will automatically configure your project. Proceed with clean/building the application (e.g. using the Maven or Gradle panel in VS Code sidebar).
- After your project is built, right-click the generated
WAR
file under thetarget
directory (Maven project) or in the build directory (Gradle project), select “Run on Server”, and select GlassFish (select No for Edit deployment parameters when asked).
- To open the application in the browser:
- Open the Explorer sidebar in VS Code
- In the SERVERS section, right click on GlassFish and select Server Actions…