Question: I'm trying to use Google protocol buffer for Java(I'm a newbie about Java, just trying).

First of all, I'm using OSX and I've installed protocol buffer with `brew install protobuf` command.

protoc command works okay.

I've generated `MyProtocol.java` by protoc.

I've installed protocol buffer for Java as its instruction(README.txt).

`mvn install` command created `.m2` directory and I can find `protobuf-java-2.4.1.jar` file somewhere in the directory.

I wrote simple test Java code just importing `MyProtocol.java` and it complains could not find package `com.google.protobuf`.

So, I've just make jar file `mvn package` and add its directory as CLASSPATH and it compiled well.

```
javac -classpath <protobuf-dir>/jara/target/classes Test.java ./com/example/tutorial/AddressBookProtos.java

```

If I use maven's repository directory (`~/.m2/repository`), it complains again.

**Doesn't maven make CLASSPATH for me if I install the package?
If not, how can I use installed package by maven to compile my code?**

Answer: 
The [Maven Dependency Plugin](http://maven.apache.org/plugins/maven-dependency-plugin/) has a goal called [`build-classpath`](http://maven.apache.org/plugins/maven-dependency-plugin/build-classpath-mojo.html) which does what you need. You can get usage hints [on the Usage page](http://maven.apache.org/plugins/maven-dependency-plugin/usage.html#The_dependency%3abuild-classpath_mojo "Usage for dependency:build-classpath")
Maven doesn't change your setup, so it's up to you to set your CLASSPATH according to your need.

However there are at least two ways in which Maven can halp you:

* You can use the [Maven Assembly plugin](http://maven.apache.org/plugins/maven-assembly-plugin/) to collect all your dependencies in a directory or an archive, so that you only need to add a single directory to your CLASSPATH in order to run your program;
* You can use the [Exec Maven plugin](http://mojo.codehaus.org/exec-maven-plugin/) to add the running of your program as a goal in your POM and then run it with Maven.