diff --git a/README.md b/README.md index 939914b4fb5e..6bd1e7211f2c 100644 --- a/README.md +++ b/README.md @@ -83,8 +83,8 @@ Most `gcloud-java` libraries require a project ID. There are multiple ways to s 1. Project ID supplied when building the service options 2. Project ID specified by the environment variable `GCLOUD_PROJECT` -3. Project ID specified in the JSON credentials file pointed by the `GOOGLE_APPLICATION_CREDENTIALS` environment variable -4. App Engine project ID +3. App Engine project ID +4. Project ID specified in the JSON credentials file pointed by the `GOOGLE_APPLICATION_CREDENTIALS` environment variable 5. Google Cloud SDK project ID 6. Compute Engine project ID diff --git a/gcloud-java-core/src/main/java/com/google/gcloud/ServiceOptions.java b/gcloud-java-core/src/main/java/com/google/gcloud/ServiceOptions.java index 5432deadaa8e..d53cfcdafe24 100644 --- a/gcloud-java-core/src/main/java/com/google/gcloud/ServiceOptions.java +++ b/gcloud-java-core/src/main/java/com/google/gcloud/ServiceOptions.java @@ -383,10 +383,10 @@ protected String defaultHost() { protected String defaultProject() { String projectId = System.getProperty(PROJECT_ENV_NAME, System.getenv(PROJECT_ENV_NAME)); if (projectId == null) { - projectId = serviceAccountProjectId(); + projectId = appEngineProjectId(); } if (projectId == null) { - projectId = appEngineProjectId(); + projectId = serviceAccountProjectId(); } return projectId != null ? projectId : googleCloudProjectId(); }