Create a Jakarta EE 8 Web Application with Payara Server and NetBeans

Photo of Rudy De Busscher by Rudy De Busscher

In this blog, we show you how you can start your next Jakarta EE application with NetBeans IDE using the plugin for the Payara Server.

It also uses the Maven or Gradle build tool, so the application can also be built outside the IDE (such as using your CI tool) as that is considered best practice.

Payara Tools in NetBeans

The Payara Tools are included by default in NetBeans as of version 11.1. You do not need to install any additional plugin to manage the Payara Server from within the IDE.  But you do need to make sure  Payara and the Java EE base plugin are active, as that is what you need to build a Jakarta Application within NetBeans.

netbeans-payara-pluginStart New Project

To get your project created, first choose the File -> New project menu item. Next, choose the Web Application option, under 'Java with Maven' or 'Java with Gradle', depending on the build tool you want to use.

On the first page of the wizard, you can define the name and the location of the project. You can also define some other information, such as the Maven coordinates, for example.

In the last step, you can define the Java enterprise version and Payara as the runtime to execute your application.

NetBeans indicates Java EE 8 Web as an option, but we can change it later on to Jakarta EE 8. But both versions have the same feature sets so they can be interchanged without any problem.

netbeans-settingsIf you have not defined the Payara Server as runtime yet, you can use the Add button and select Payara Server.

netbeans-choose-serverAnd lastly, you can define the location where you have unzipped the Payara download, or you can just point to an empty directory and download a Payara version automatically.

netbeans-payara-locationChange to Jakarta EE 8

As mentioned, Java EE 8 and Jakarta EE 8 contain the same functionalities. There is no problem with building a Java EE 8 application and running it on the Jakarta EE certified Payara Server.  If you would like to change the dependencies in the build configuration, here is what you need to do:

Within the pom.xml file, replace the javaee-api artifact with the Jakarta one:

<dependency>
    <groupId>jakarta.platform</groupId>
    <artifactId>jakarta.jakartaee-web-api</artifactId>
    <version>8.0.0</version>
    <scope>provided</scope>
</dependency>

 

Or, if you prefer Gradle, you can use the following dependency line:

providedCompile 'jakarta.platform:jakarta.jakartaee-web-api:8.0.0'

Run Application

Since the New project wizard creates a default startup page and a JAX-RS endpoint, you can run the application and see the result in the browser immediately. Just press the run icon or use the run menu and you will get the HTML page as result.

netbeans-run-appIn case you want to test out the JAX-RS endpoint, you can point your browser to http://localhost:8080/mavenproject1/resources/javaee8

Conclusion

NetBeans has a new project wizard that allows you to create a Java EE 8 application. Using that same wizard you can select Payara Server as the runtime for your application. You can even download and install a Payara Server installation directly from this wizard.

Once the project is created and all build tools files are in place, you can immediately start your program and test it out. If you like to use the Jakarta EE 8 dependencies, a small change to the build tools files is required.

 

Comments