Home > Mobile >  Javafx calling REST API In desktop application
Javafx calling REST API In desktop application

Time:03-18

I am developing pathology lab management desktop app in Javafx and wanted to use JPA from spring project. Actually it will be spring application with Javafx and JPA. So I wanted to ask if i can call rest end points in desktop application.

CodePudding user response:

I assume you have a (spring) rest server and a java(fx) client. In the client you could go something like this:

...
import jakarta.ws.rs.client.Client;
import jakarta.ws.rs.core.Response;
import java.net.URI;
...
class <your class>
{
    Client client;
...
    void <your method>
    {
...
        client = ClientBuilder.newClient();
...
        URI uri = URI.create(<your rest server uri>);

        Response response = client.target(uri).request().get();
        <your_java_type> entity = response.readEntity(<your_java_type>.class);
...
    }
...
}

Is that what you are looking for?

  • Related