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:
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:
Answer the prompts (groupId, artifactId, etc) to set up the project:
Enter the context path of application:
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:
As you can see, the project has a basic structure with srcmainjava and srcmainwebapp folders:
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:
After starting the instance, you may see the 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”.
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:
You may also modify the jdk home path setting from the settings.json by updating the java.home property.
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.
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.
Great extension, works really well with the standalone version!
Would be great if this extension were also supported by visual studio online – https://github.com/cdr/code-server
Imagine to have a embedded online ide with hot deployment of my payara micro project 😉
Thanks for the blog! I followed all of the instructions and everything completed with out error. All of the maven plugins and dependencies look fine. When I expand the Payara Micro Instances pane on the left there is not a Payara Micro Instance. I have tried a couple different versions of the archetype but none of them end up creating an instance. Am I missing a step or is there a manual way to add the instance?
Use payara-micro-maven-archetype to create the Payara Micro project, Payara VSCode tools already supports generating new Payara Micro project. If the Payara Micro instance is not visible in the side panel then check the existence of the payara-micro-maven-plugin in pom.xml and also share the log from the Developer console (F12) for further assistance.
How to configure maven home? payara tool says to me something like “error execute maven because maven home not found”. indeed my system doesn’t have maven_home, m2_home, etc. but maven works fine outside vscode.
Great extension, works really well with the standalone version!
Would be great if this extension were also supported by visual studio online – https://github.com/cdr/code-server
Imagine to have a embedded online ide with hot deployment of my payara micro project 😉
Using this extension on vscode online
https://github.com/humbertodias/payara-ide
Thanks
Hi Humberto, Thanks for using the Payara tools and sharing the info for code-server, we will review and update.
Thanks for the blog! I followed all of the instructions and everything completed with out error. All of the maven plugins and dependencies look fine. When I expand the Payara Micro Instances pane on the left there is not a Payara Micro Instance. I have tried a couple different versions of the archetype but none of them end up creating an instance. Am I missing a step or is there a manual way to add the instance?
Hi Shane,
Use payara-micro-maven-archetype to create the Payara Micro project, Payara VSCode tools already supports generating new Payara Micro project. If the Payara Micro instance is not visible in the side panel then check the existence of the payara-micro-maven-plugin in pom.xml and also share the log from the Developer console (F12) for further assistance.
How to configure maven home? payara tool says to me something like “error execute maven because maven home not found”. indeed my system doesn’t have maven_home, m2_home, etc. but maven works fine outside vscode.