Hello Analytics API: Java quickstart for installed applications

This tutorial walks through the steps required to access a Google Analytics
account, query the Analytics APIs, handle the API responses, and output the
results. The Core Reporting API v3.0,
Management API v3.0, and OAuth2.0
are used in this tutorial.

Step 4: Run the sample

After you have enabled the Analytics API,
installed the Google APIs client library for Java,
and set up the sample source code the sample is ready to run.

If you're using an IDE, make sure you have a default run target set
to the HelloAnalytics class.

The application will load the authorization page in a browser.

If you are not already logged into your Google account, you will be
prompted to log in. If you are logged into multiple Google accounts,
you will be asked to select one account to use for the authorization.

When you finish these steps, the sample outputs the name of the
authorized user's first Google Analytics view (profile) and
the number of sessions for the last seven days.

Note: To successfully run this sample
you will need to have at least one Google Analytics property and view
(profile).