Simple Microservice Client Using J-Framework

This example demonstrates the usage of the j-framework in creating a simple microservice client.


  1. You should have JDK 17+ Installed. (Click Here).

  2. You should have a simple microservice running. (Click Here)

  3. You should create a Maven Project.

  4. You should enable snapshot versions. (Click Here).

Project Content:

This section contains what you should add to your code structure for this example.

  1. Maven Project with pom.xml that has the following contents:

<project xmlns=""
  1. Java Person class is located at src/main/java/com/app/ that has the following content:


public class Person {

	private String name;

	private int age;

	public String getName() {
		return name;

	public void setName(String name) { = name;

	public int getAge() {
		return age;

	public void setAge(int age) {
		this.age = age;

  1. Server URL Configuration file located at src/main/resources/ which contains the following:

  1. Main java class located at src/main/java/com/app/ which contains the following:


import com.jk.core.util.JK;

public class App {
	public static void main(String[] args) {
		String url = "http://localhost:8080/app/example";
		JKServiceClient<Person> client = new JKServiceClient<>(url, Person.class);

		String response = client.callJsonAsString("/hello");

		String response2 = client.callJsonAsString("/hello/Jalal");

		Person p = new Person();

		String response3 = client.callJsonWithPost("/hello", p);

		String response4 = client.callJsonWithPatch("/hello", p);

Alternatively, you can clone or download the tutorial repository then import the project into your IDE.

How to run Project:

  1. Set up the project with the content shown above.

  2. Inside your IDE, go to the src/main/java/com/app/ class.

Main Class

  1. Next, run it as a Java Application.

Run as Java Application

  1. Your program will start running and show you the result of the run in the console.

console output

Example Explanation

  1. The first output line the client receives is the result from the server sending their default greetings.

  2. The second output line is a custom greeting message that contains the client’s name in it.

  3. The final line of the output is a custom greeting message that contains both the client’s name and their age retrieved from the Person object’s attributes which represent the client.

  4. Check the main method to see how the client and server communicated to produce this output.