GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — java-docs-samples/storage/xml-api/cmdline-sample at master · SurferJeffAtGoogle/java-docs-samples

Expand file tree

/

cmdline-sample

/
Copy path

Directory actions

More options

More options

Directory actions

More options

More options

Latest commit

 

History

History
History
 
 
/

cmdline-sample

/
Copy path

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
src
src
 
 
README.md
README.md
 
 
logging.properties
logging.properties
 
 
pom.xml
pom.xml
 
 

README.md

Outline

This is the sample used in the Cloud Storage Java documentation.

Open in Cloud Shell

Using the Command Line Sample

Browse Online

The main file is StorageSample.java.

Setup

  • Create a Google Cloud Storage bucket

  • This module uses Application Default Credentials. If you are running it outside of Google Compute Engine, you'll need to

    • Download the json private key for a Service Account and have it available.
    • Set an environment variable: export GOOGLE_APPLICATION_CREDENTIALS=path/to/your-key.json
  • You must also be able to work with GitHub repositories.

  • Clone repository.

      git clone https://github.com/GoogleCloudPlatform/java-docs-samples.git
    

Command-line Instructions

  • Prerequisites:
    • Install the latest version of Java and Maven.
    • Set the environment variable: export GOOGLE_APPLICATION_CREDENTIALS=your-key-filename.json
    • You may need to set your JAVA_HOME.
cd java-docs-samples/storage/xml-api/cmdline-sample
# Compile and run
mvn compile install
mvn -q exec:java -Dexec.args="your-bucket-name"

To enable logging of HTTP requests and responses (highly recommended when developing), please take a look at logging.properties.

Eclipse Instructions

  • Prerequisites:

    • Install Eclipse, the Maven plugin, and optionally the GitHub plugin.
  • Set up Eclipse Preferences

    • Window > Preferences... (or on Mac, Eclipse > Preferences...)

    • Select Maven

      • check on "Download Artifact Sources"
      • check on "Download Artifact JavaDoc"
  • Create a new project using storage/xml-api/cmdline-sample

    • Create a new Java Project.
    • Choose the Location of the project to be the location of cmdline-sample
    • Select the project and Convert to Maven Project to add Maven Dependencies.
    • Click on Run > Run configurations
      • Navigate to your Java Application's configuration section
      • In the Arguments tab, add the name of the bucket you created above as a Program argument
      • In the Environment tab, create a variable GOOGLE_APPLICATION_CREDENTIALS and set it to the path to your json private key file.
  • Run

    • Right-click on project
    • Run As > Java Application
    • If asked, type "StorageSample" and click OK
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.