Jakarta EE Development

Jakarta EE Many tools and libraries from the Integrated Development Environment (IDE) can be used for development.

Integrated Development Environment (IDE)

An IDE can help in creating, testing, and deploying applications. Examples of IDEs for Jakarta EE development include Eclipse, NetBeans, and IntelliJ IDEA.

Libraries

Jakarta EE relies on various libraries and APIs. These libraries should be included in the classpath during development. Some common libraries include Servlet API, JSP API, JavaBeans Activation Framework, Java Persistence API, and Java Message Service API.

Java Development Kit (JDK)

The JDK provides the tools and libraries required for Jakarta EE development. The latest LTS version of the JDK is recommended for use with Jakarta EE.

Build Tool

A build tool can be used to automate the build process. Examples of build tools include Apache Maven, Apache Ant, and Gradle.

Application Server

An application server is required to deploy and run Jakarta EE applications. Examples of application servers include GlassFish, Payara, WildFly, and TomEE.

Continuous Integration (CI) Tool

A CI tool can be used to automate the integration process and detect integration errors early in the development lifecycle. Examples of CI tools include Jenkins, GitLab CI/CD, and CircleCI.

Here is an example of how you can create a simple Jakarta EE web application using Eclipse and GlassFish:

Download and install Eclipse and GlassFish.

Ensure to open Eclipse and create a new “Dynamic Web Project”.

Right-click on the project, go to “Properties”, and set the “Project Facets”. Check “Java” and choose the appropriate version, and check “Dynamic Web Module” and choose the appropriate version.

Meanwhile, in the project window, create a new class called “HelloServlet”. This class should extend the “HttpServlet” class and override the “doGet” method.

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet("/HelloServlet")
public class HelloServlet extends HttpServlet {
private static final long serialVersionUID = 1L;

protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.getWriter().append("Hello World!");
            }
}

In the “WEB-INF” directory, make a new file named “web.xml” in the provided project window. However, the file should hold the below code as displayed: 

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
id="WebApp_ID" version="3.1">
<display-name>Archetype Created Web Application</display-name>
<servlet>
<servlet-name>HelloServlet</servlet-name>
<servlet-class>com.example.HelloServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloServlet</servlet-name>
<url-pattern>/HelloServlet</url-pattern>
</servlet-mapping>
</web-app>

Running the application

From the given window, ensure to right-click on the project

Ensure to move the mouse pointer and select “Run As

Click next on “Run on Server”.

Ensure to select or make a choice by picking GlassFish

Select and click on “Finish”.

Open a web browser and navigate to “http://localhost:8080/HelloServlet“. You should see the message “Hello World!”.

By following these steps, you can begin developing your own Jakarta EE applications.

Related posts:

About Author


Discover more from SURFCLOUD TECHNOLOGY

Subscribe to get the latest posts sent to your email.

Leave a Reply

Your email address will not be published. Required fields are marked *

Discover more from SURFCLOUD TECHNOLOGY

Subscribe now to keep reading and get access to the full archive.

Continue reading