This example is a "hello world" application, using the Bigtable HBase client library for Java, that illustrates how to:

  • Set up authentication
  • Connect to a Bigtable instance.
  • Create a new table.
  • Write data to the table.
  • Read the data back.
  • Delete the table.

Set up authentication

To use the Java samples on this page in a local development environment, install and initialize the gcloud CLI, and then set up Application Default Credentials with your user credentials.

  1. Install the Google Cloud CLI.

  2. If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.

  3. If you're using a local shell, then create local authentication credentials for your user account:

    gcloud auth application-default login

    You don't need to do this if you're using Cloud Shell.

    If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.

For more information, see Set up authentication for a local development environment.

Running the sample

The sample uses the HBase APIs to communicate with Bigtable. The code for this sample is in the GitHub repository GoogleCloudPlatform/cloud-bigtable-examples, in the directory java/hello-world.

To run this sample program, follow the instructions for the sample on GitHub.

Using the HBase APIs

The sample application connects to Bigtable and demonstrates some simple operations.

Installing and importing the client library

This sample uses the Bigtable HBase client for Java, as well as Maven. See the instructions for using the client library.

The sample uses the following imports:

Connecting to Bigtable

Connect to Bigtable using the BigtableConfiguration class.

Creating a table

Use the Admin API to create a table.

Writing rows to a table

Use the Table class to put rows to the table. For better throughput, consider using the BigtableBufferedMutator class.

Reading a row by its key

Get a row directly using its key.

Scanning all table rows

Use the Scan class to get a range of rows.

Deleting a table

Delete a table using the Admin API.

Putting it all together

Here is the full example without comments.

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026-03-30 UTC.