Payara Micro VSCode Tooling

Photo of Gaurav Gupta by Gaurav Gupta

 

In this tutorial, I will explain how to create, run and debug a Payara Micro application in Visual Studio Code. (If you're interested in learning more about using Payara Server in VSCode, please checkout ourprevious blogs.)

Prerequisite VSCode Extensions

Before going through this tutorial, you must install the following extensions from the Visual Studio Code marketplace:

You can install extensions from Extensions view (Ctrl + Shift + X) in the activity bar of VS Code:payara tools

Creating a Payara Micro Application

Maven is the most widely used project build and dependency management tool in the Java ecosystem. So in this tutorial we will generate a Payara Micro Maven Web Application through the Payara Micro Maven archetype.

Let’s start:

  • Open the command pallet using Ctrl + Shift + P, type Payara Micro and select the Generate a Payara Micro Project option:
payara micro maven web application
  • Answer the prompts (groupId, artifactId, etc) to set up the project:
set up the project in maven
  • Enter the context path of application:
Enter the context path of application:
  • Select the Payara Micro version:
Select the Payara Micro version:
  • Select the destination folder, where the project will be generated. Once the project is generated, you may either add the project to the current workspace or open in a new window:
src\main\java and src\main\webapp folder
  • As you can see, the project has a basic structure with src\main\java and src\main\webapp folders:
project has a basic structure

Running the Payara Micro Application:

  • In the explorer sidebar (or Payara activity bar), expand Payara Micro Instances, right click on the instance and select start:
expand Payara Micro Instances
  • After starting the instance, you may see the Payara Micro application log in the OUTPUT window:
Payara Micro application log in the OUTPUT window
  • Similarly you may also start the instance in the debug mode and you may also modify the debug configuration from the launch.json config named “payara-micro”.
start the instance in the debug mode

Advanced Settings

JDK Home Path

To modify the JDK Home Path of the application, right click on the Payara Micro instance, select JDK Home and browse the JDK Home path:

modify the JDK Home Path of the application

You may also modify the jdk home path setting from the settings.json by updating the java.home property.

modify the jdk home path setting from the settings.json

Customize Build Commands:

Payara Micro application lifecycle commands like start, stop, reload and bundle can be modified as per developer choice by overriding these command instructions in the tasks.json.

commands like start, stop, reload and bundle can be modified

Now that we can run Payara Micro applications without leaving VSCode, it's time to write some code! For inspiration, check out the Payara Examples repository on GitHub for some sample applications.

Download Payara Micro
Download

 

 

Comments