This page describes how to generate a client library from your backend API.
Any Java or Android app can use this library to call the API.

To create iOS clients for your API, we recommend that you use
[Google APIs Objective-C Client Library for REST APIs](https://github.com/google/google-api-objectivec-client-for-rest/wiki).

## Before you begin

- [Set up your development environment](https://docs.cloud.google.com/endpoints/docs/frameworks/java/set-up-environment.md.txt).
- Make sure you have properly [annotated](https://docs.cloud.google.com/endpoints/docs/frameworks/java/annotate-code.md.txt) your API.

## Generating the client library

The following instructions demonstrate how to use the Cloud Endpoints Frameworks
[Apache Maven](https://docs.cloud.google.com/endpoints/docs/frameworks/java/maven-endpoints-frameworks-plugin.md.txt)
and [Gradle](https://docs.cloud.google.com/endpoints/docs/frameworks/java/gradle-endpoints-frameworks-plugin.md.txt)
plugins to generate a Gradle client bundle from the sample Maven project
[Getting started with Endpoints](https://docs.cloud.google.com/endpoints/docs/frameworks/java/quickstart-frameworks-java).

To generate a client library:

1. Build your API

2. Run the Endpoints Frameworks command-line tool similarly to the
   following:

   ### Maven

   ```bash
   mvn endpoints-framework:clientLibs
   ```

   ### Gradle

   ```bash
   gradle endpointsClientLibs
   ```

   Wait for the tool to generate the library; on success the tool displays a
   message similar to this one:

   ### Maven

   ```
   API client library written to target/client-libs/echo-v1-java.zip
   ```

   ### Gradle

   ```
   API client library written to build/endpointsClientLibs/echo-v1-java.zip
   ```
3. Unzip the file by using the unzip utility, or use another ZIP-compatible
   unarchiving utility:

   ```java
   unzip ./echo-v1-java.zip
   ```
4. Change directory:

   ```java
   cd echo
   ```
5. Build the client library:

   ### Maven

   ```bash
   mvn clean package
   ```

   The output is in the `target/` directory.
   The exact filename depends on the version of the Java client. It is
   something similar to `echo-v1-1.23.0-SNAPSHOT.jar`.

   ### Gradle

   ```bash
   gradle build
   ```

   The output is in the `build/libs` directory. The
   exact filename depends on the version of the Java client. It is
   something similar to `echo-v1-1.23.0-SNAPSHOT.jar`.
6. Add the client library JAR to your Java or Android app.

7. Repeat these steps every time you modify your API code.

## What's next

- [Call the backend API from an Android app](https://docs.cloud.google.com/endpoints/docs/frameworks/java/calling-from-android.md.txt).
- [Learn more about Cloud Endpoints Frameworks for App Engine](https://docs.cloud.google.com/endpoints/docs/frameworks/java).