diff --git a/gcloud-java-examples/README.md b/gcloud-java-examples/README.md index e70384a1bf92..991e0ef5fd91 100644 --- a/gcloud-java-examples/README.md +++ b/gcloud-java-examples/README.md @@ -20,6 +20,35 @@ Add this to your pom.xml file ``` +To run examples from your command line: + +1. Login using gcloud SDK (`gcloud auth login` in command line) + +2. Set your current project using `gcloud config set project PROJECT_ID` + +3. Compile using Maven (`mvn compile` in command line from your base project directory) + +4. Run an example using Maven from command line. + + Here's an example run of `DatastoreExample`. + + Note that you have to enable the Google Cloud Datastore API on the [Google Developers Console][developers-console] before running the following commands. + ``` + $mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.DatastoreExample" -Dexec.args="my_name add my\ comment" + $mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.DatastoreExample" -Dexec.args="my_name display" + $mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.DatastoreExample" -Dexec.args="my_name delete" + ``` + + Here's an example run of `StorageExample`. + + Before running the example, go to the [Google Developers Console][developers-console] to ensure that Google Cloud Storage API is enabled and that you have a bucket. Also ensure that you have a test file (`test.txt` is chosen here) to upload to Cloud Storage stored locally on your machine. + ``` + $mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.StorageExample" -Dexec.args="upload /path/to/test.txt " + $mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.StorageExample" -Dexec.args="list " + $mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.StorageExample" -Dexec.args="download test.txt" + $mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.StorageExample" -Dexec.args="delete test.txt" +``` + Contributing ------------ @@ -50,3 +79,4 @@ Apache 2.0 - See [LICENSE] for more information. [CONTRIBUTING]:https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/CONTRIBUTING.md [LICENSE]: https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/LICENSE [cloud-platform]: https://cloud.google.com/ +[developers-console]:https://console.developers.google.com/