Instructions for the Google Books V1 JSON Command-Line Sample
Browse Online
Register Your Application
- Visit the Google
apis console
- If this is your first time, click "Create project..."
- Otherwise, click on the drop down under the "Google apis" logo at
the top left, and click "Create..." under "Other projects"
- Activate the Books API and agree to the terms of service
- Click on "API Access"
- Enter the "API Key" shown under "Simple API Access" into the API_KEY
constant found in class com.google.api.services.samples.books.cmdline.ClientCredentials
Checkout Instructions
Prerequisites: install Java 6, Mercurial and Maven. You may need to
set your
JAVA_HOME
.
cd [someDirectory]
hg clone https://code.google.com/p/google-api-java-client.samples/ google-api-java-client-samples
cd google-api-java-client-samples/books-cmdline-sample
[editor] src/main/java/com/google/api/services/samples/books/cmdline/ClientCredentials.java
mvn compile
mvn -q exec:java -Dexec.args=Google
To enable logging of HTTP requests and responses (highly recommended
when developing), please take a look at logging.properties.
Setup Project in Eclipse
Prerequisites: install Eclipse,
the Mercurial plugin, and the
Maven
plugin.
- Setup Eclipse Preferences
- Window > Preferences... (or on Mac, Eclipse >
Preferences...)
- Select Maven
- check on "Download Artifact Sources"
- check on "Download Artifact JavaDoc"
- Import
books-cmdline-sample project
- File > Import...
- Select "General > Existing Project into Workspace" and click
"Next"
- Click "Browse" next to "Select root directory", find
[someDirectory]/google-api-java-client-samples/books-cmdline-sample
and click "Next"
- Click "Finish"
- Run
- Right-click on project books-cmdline-sample
- Run As > Java Application
- If asked, type "BooksSample" and click OK
- To run:
- Run > Run Configurations...
- Click on "Java Application > BooksSample"
- Click on "Arguments" tab
- Program arguments:
"Mark Twain"
- See comments in BooksSample.java
for full command line arguments.
- VM arguments:
-Djava.util.logging.config.file=${project_loc}/logging.properties
- Click "Run"