Payara Server tools in VS Code

Adding Payara Server to VS Code

  1. Open the command pallet using Ctrl + Shift + P, type Payara and select the Add Payara Server option.

  2. Browse the Payara Server installation path (recently used servers location are listed by default).

  3. Choose a name for the server.

  4. Then select a domain from the list or create a new domain by pressing the + button.

Add Payara Server

Managing Payara Server from VS Code

Once Payara Server is added to VS Code it can be found under the Payara Servers explorer panel with the configured name. Right-clicking on the server lets you perform any of the following actions:

  • Start, restart or stop the server

  • Start debugging the server

  • Rename or remove the server

  • Open admin console

  • Open server log

  • Open server domain.xml config

  • Update admin credentials

  • Update JDK path

Start Payara Server

Managing Applications on Payara Server

Deploying Applications

An application can be deployed to Payara Server easily though VS Code. Applications can be deployed via either of the following two methods

Right-click on the application and select Run on Payara Server to deploy the application:

Deploy application

Alternatively, an application can be deployed from the Java Projects interface:

Deploy application

Undeploying Applications

Deployed applications can be opened in the browser, undeployed or disabled by right-clicking on the application in the Payara Servers interface:

Open application homepage

Deploy Applications in a Local Docker Container

The Payara Server tools for the VS Code extension includes Docker integration, making it seamless to deploy exploded applications to a Payara Server instance running within a local Docker container.

To take advantage of this feature, follow these steps below:

  1. Register a new Payara Server instance by performing the following:

    1. Open the command pallet using Ctrl + Shift + P, type Payara and select the Add Payara Server option.

    2. Select Remote Domain.

    3. For Docker integration, choose the "Docker" type and provide the HOST_PATH (e.g., D:/test) and CONTAINER_PATH (e.g., /mnt/test) mapping details.

      This mapping should align with the exploded application path or parent path of exploded application.

    4. Choose a name for the server.

    5. Enter the domain name, host name, and necessary credentials.

  2. Run the Payara Server Docker container using the following command:

    docker run -p 8080:8080 -p 4848:4848 -p 9009:9009 -v HOST_PATH:CONTAINER_PATH  payara/server-full:{page-version}

    Replace HOST_PATH with the actual host path and CONTAINER_PATH with the desired container path. The HOST_PATH points to the location on your host machine, and CONTAINER_PATH is the corresponding location inside the container.

  3. Create your web application and deploy it to the registered Payara Server instance.

Deploy Applications in a WSL Environment

Another noteworthy feature is the integration of the Payara Server Tools with Windows Subsystem for Linux (WSL).

This integration empowers developers to manage and deploy exploded applications to a Payara Server instance running within WSL.

Here’s how you can make use of this feature:

  1. Start the Payara Server instance within WSL:

    1. Run the following command to start the server:

      ./asadmin start-domain
    2. Set a password for the admin user:

      ./asadmin change-admin-password
    3. Enable secure admin:

      ./asadmin enable-secure-admin
    4. Restart the Payara Server domain:

      ./asadmin restart-domain
    5. Fetch the IP address of WSL environment using the command hostname -I and enter it in the host name field in the VS Code settings.

  2. Register the WSL-based Payara Server instance in VS Code:

    1. Open the command pallet using Ctrl + Shift + P, type Payara and select the Add Payara Server option.

    2. Select Remote Domain.

    3. For WSL integration, choose the WSL instance type.

    4. Choose a name for the server.

    5. Enter the domain name, host name (fetched via the command hostname -I in WSL instance), and necessary credentials.

  3. Create your web application and deploy it to the registered Payara Server instance.

Hot Deploy and Auto Deploy Settings

Hot Deploy and Auto Deploy can be enabled in Visual Studio Code IDE from the Deployment Settings of Payara Server:

Deployment Settings
Enable Hot Deploy