Jersey Java RESTful API on an Alibaba Cloud ECS Instance


REST means “Representational State Transfer”. REST was intended to create a decoupling between the server and the client, maintain reusable components, and can be replaced at any time. REST is stateless and you can implement cache on the server to improve performance and efficiency.

  • Eclipse IDE for JAVA EE Developers
  • Latest Maven
  • Apache Tomcat web server 7
  • Insomnia REST Client

Creating the API:

Download the latest “Eclipse IDE for JAVA EE Developers” and install.

  • You need to install the latest version of JDK & set the installation path to “JAVA_HOME” & also to the “Path” environment variables
  • You also need to install maven. It is so simple you need to download the latest binary distribution .zip and extract it & set the installation path to the “M2_HOME” & “Path” environment variables.
<project xmlns="" xmlns:xsi=""
<name>RESTfulExample Maven WebApplication</name>
<name> Repository for Maven</name>

</dependencies> <build>
package com.aditya.model;public class Employee {    private String name;
private String age;
private int salary;
private String company;
public String getName() {
return name;
public void setName(String name) { = name;
public String getAge() {
return age;
public void setAge(String age) {
this.age = age;

public int getSalary() {
return salary;
public void setSalary(int salary) {
this.salary = salary;
public String getCompany() {
return company;
public void setCompany(String company) { = company;
public String toString() {
return "Employee [name=" + name + ", age=" + age + ", salary=" + salary + ", company=" + company + "]";
import com.aditya.model.Employee;@Path("/json/empservice")
public class JSONService {
public Employee getEmpDetails() {
Employee emp = new Employee();
emp.setCompany("ABC Corporation");
return emp; } @POST
public Response createEmpInJSON(Employee emp) {

String result = "Employee saved : " + emp.toString();
return Response.status(201).entity(result).build();


<web-app id="WebApp_ID" version="2.4"
xmlns="" xmlns:xsi=""
<display-name>Restful Web Application</display-name>

Apache Tomcat 7:

Download the Windows installer at the official link

Deploying and Testing the API:

Additional Steps:

1.In Production, you can reduce the cost by using the Version 1709 Windows server Image which only gives the console based access, But it cuts a lot of software on your ECS Instance increasing the performance.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Alibaba Cloud

Alibaba Cloud

Follow me to keep abreast with the latest technology news, industry insights, and developer trends. Alibaba Cloud website: