Search code examples
jax-rswebservices-client

Difference between ClientFactory and ClientBuilder in JAX-RS


What's the difference between creating a new Client instance using ClientFactory and ClientBuilder in JAX-RS?


Solution

  • The ClientFactory class does not exist in the Client API, introduced in JAX-RS 2.0. Have a look at the javax.ws.rs.client package.

    The ClientFactory class was present in the release candidates and milestones of the JAX-RS 2.0 specification, but was replaced with the ClientBuilder class. For more details, you can check the old versions of the javax.ws.rs-api artifact.

    To create Client instances, use ClientBuilder:

    Client client = ClientBuilder.newClient();