code: public static String getDefaultProjectId() {
      String projectId = System.getProperty(PROJECT_ENV_NAME, System.getenv(PROJECT_ENV_NAME));
      if (projectId == null) {
        projectId =
            System.getProperty(LEGACY_PROJECT_ENV_NAME, System.getenv(LEGACY_PROJECT_ENV_NAME));
      }
      if (projectId == null) {
        projectId = getAppEngineProjectId();
      }
      if (projectId == null) {
        projectId = getServiceAccountProjectId();
      }
      return projectId != null ? projectId : getGoogleCloudProjectId();
    }
docs: Returns the default project ID, or {@code null} if no default project ID could be found. This
  method returns the first available project ID among the following sources:
  
  <ol>
  <li>The project ID specified by the GOOGLE_CLOUD_PROJECT environment variable
  <li>The App Engine project ID
  <li>The project ID specified in the JSON credentials file pointed by the {@code
  GOOGLE_APPLICATION_CREDENTIALS} environment variable
  <li>The Google Cloud SDK project ID
  <li>The Compute Engine project ID
  </ol>