Saturday, October 2, 2010

Google Document List API NetBeans sample

I've recently been doing work in Java using Google's Document List API v3.0. It's well documented and there are some basic "Hello World" samples available, but not a single sample that fully demonstrates the basics of using the API.

In teaching myself the API, that's where I started. I took a lot of the code from their documentation pages, and created a single NetBeans project that connects to Google Docs, lists your documents, creates a new folder, creates a new file in that folder, etc. It was a good starting point for the app I was building, and is probably a good starting point for anyone else who wants to build an app that interfaces with Google Docs.

One of the most annoying parts of creating the project was figuring out just the dependencies that were needed, and getting those .jar files in the right place. For convenience, I include all the necessary .jar files in the download. They're in the Libraries/ directory, and are already referenced by the project.

You can download the sample here: http://www.arbingersys.com/dnlds/GDocsSample.zip

If you have NetBeans installed, simply choose File | Open Project and browse to the GDocsSample/ folder that you've extracted from the archive.

Under Source Packages double-click Main.java and it will open in the editor. On line 59 you'll want to modify the client.setUserCredentials() call with your Gmail credentials. Then you should be ready to build and run the project.

Enjoy!

4 comments:

  1. Hi,

    This code looks interesting. Thanks for the effort and sharing the code with us. I tried the code and it works for me.

    with regards
    Tushar

    ReplyDelete
  2. Thanks Tushar, good to hear.

    ReplyDelete
  3. took me exactly two minutes...wow i'm impressed.keep up the good work.

    Ta,
    Doctor

    ReplyDelete