# Installing the Data Source Java Library

This page describes how to use or modify the Google Visualization Java library,
and how to contribute to the open source code for the project.

## Contents

1. [Requirements](https://developers.google.com/chart/interactive/docs/dev/dsl_install#requirements)
2. [Dependencies](https://developers.google.com/chart/interactive/docs/dev/dsl_install#dependencies)
3. [Using the Library as Provided](https://developers.google.com/chart/interactive/docs/dev/dsl_install#usingthelibrary)
4. [Running the Examples](https://developers.google.com/chart/interactive/docs/dev/dsl_install#buildingexamples)
5. [Modifying the Library](https://developers.google.com/chart/interactive/docs/dev/dsl_install#build_self)
6. [Contributing to the Open Source Project](https://developers.google.com/chart/interactive/docs/dev/dsl_install#contributing)

## Requirements

You must have the following components in order to use the Google Visualization
Java library:

- A servlet container and the Servlet API version 2.4 or higher. One of the most commonly used servlet containers is Apache Tomcat, which includes the Servlet API. See <http://tomcat.apache.org/download-55.cgi> to download the binary for version 5.5. You need install only the Core module. You also need Tomcat to complete the tutorial sections: [Getting
  Started](https://developers.google.com/chart/interactive/docs/dev/dsl_get_started), [Using an External Data Store](https://developers.google.com/chart/interactive/docs/dev/dsl_csv), and [Defining
  Capabilities and the Flow of Events](https://developers.google.com/chart/interactive/docs/dev/dsl_httpservlet).
- The [Java Development Kit](http://java.sun.com/) version 6.0 or greater.

  **Note** : It is also possible to use the JDK
  version 5.0. However, you must then remove `@Override` from
  every method in the library that overrides an interface method. This is
  due to the change in the `@Override` annotation behavior in
  JDK version 6.0.

## Dependencies

The data source Java library has the following dependencies. The library was
tested with the versions listed; other versions might be acceptable, but have not
been tested.

**Included in the source or download:**

- [icu4j](http://site.icu-project.org/) version 4.0.1.
- [Jakarta commons lang](http://commons.apache.org/lang/) version 2.4.
- [Jakarta commons logging](http://commons.apache.org/logging/) version 1.1.1.
- [Google collections
  library](http://code.google.com/p/google-collections/) version 1.0.
- [*javacc*](https://javacc.dev.java.net/) version 4.2. This is required only if you intend to compile the libraries, for example when modifying them as described [below](https://developers.google.com/chart/interactive/docs/dev/dsl_install#build_self).
- [*opencsv*](http://opencsv.sourceforge.net/) version 1.8. This is required only if you intend to use a CSV data source.

**Not included in the source or download:**

- To use the `SqlDataSourceHelper` class with a mySQL database, you also need `mysql.jar` in your runtime environment. See: <http://www.mysql.com/products/connector/j/> for details and downloadable versions.

## Using the Library as Provided

This section describes how to use the visualization Java library if you don't
need to modify it. This process varies with your build system:

**If using [Maven](http://maven.apache.org/index.html),** set
up a dependency on the visualization library with the following settings:

- Group ID: com.google.visualization
- Artifact ID: visualization-datasource
- Version number: Use the latest version number listed on the [project
  page](http://code.google.com/p/google-visualization-java/).

**If using any other build system**:

- [Download
  the library ZIP file](http://code.google.com/p/google-visualization-java/) from the project page, unzip the files, and include them in your project as your build system requires.

## Running the Examples

The JAR example files are included along with the library JARs in the [downloadable
ZIP file](http://code.google.com/p/google-visualization-java/). Instructions on running the examples are given on the [Getting
Started](https://developers.google.com/chart/interactive/docs/dev/dsl_get_started) page.

## Modifying the Library

If you want to modify the library code, you'll have to download the source from
the open source hosting site and build it. Before doing this, read the licensing
information linked to by the "Code license" section on the [project
page](http://code.google.com/p/google-visualization-java/) to see whether your use case is allowed.

Here are the steps for downloading and building the library:

1. **Download the source code** using SVN, as described in on the **Source \> Checkout** tab on the [open
   source project page](http://code.google.com/p/google-visualization-java/source/checkout).
2. **Build your code.** If building in Maven, use the pom.xml file provided with the source. If building with [Apache
   Ant](http://ant.apache.org/), follow the instructions given next (note that the code has been tested with Ant version 1.7.0; if you have an earlier version of Ant, you might need to upgrade)

### Ant Build Instructions

**1. Modify your build properties:**

1. Navigate to the `build-src` subdirectory of your chosen installation directory.
2. Using a text editor, open the `build.properties` file and make the following changes:
   - Edit the `servlet-api.jar` property to point to your `servlet-api.jar` file. For example, if you installed Tomcat to your `c:` drive in the `tomcat_home` directory, then you would specify the `servlet-api.jar` property as follows:  
     `servlet-api.jar=C:/tomcat_home/common/lib/servlet-api.jar`

     **Note**: Use forward slashes rather than
     backslashes in the file path, even when using Windows
   - To use your own copies of the dependencies described above, edit the paths in the same build.properties file.

**2. Build the library:**

Navigate the `build-src` subdirectory in the file and type one of the
following:

- `ant datasource` - Builds the data source library
- `ant example` - Builds the examples
- `ant` - Builds both data source and examples
- `ant test` - Builds and runs the data source library tests. Very useful when you are modifying the library.

## Contributing to the Open Source
Project

If you want to contribute changes to the open source project, you'll have to get
submission permissions to the project. Send an email to [google-visualization-api@googlegroups.com](mailto:google-visualization-api@googlegroups.com) asking
for permission and instructions on how to submit changes.