Skip to content

Commit 2f37c82

Browse files
committed
Further simplify java Hello World
- Go back to using plugin to detect os - Remove unnecessary maven config for packaging - Use system properties for project/zone/cluster for consistency with other examples.
1 parent 4b5bd42 commit 2f37c82

File tree

1 file changed

+13
-5
lines changed
  • bigtable/hbase/snippets/src/main/java/com/example/cloud/bigtable/helloworld

1 file changed

+13
-5
lines changed

bigtable/hbase/snippets/src/main/java/com/example/cloud/bigtable/helloworld/HelloWorld.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,20 @@ private static void print(String msg) {
120120
}
121121

122122
public static void main(String[] args) {
123-
if (args.length < 3) {
124-
System.err.println("Usage: HelloWorld <projectId> <zone> <clusterId>");
125-
System.exit(1);
126-
}
123+
// Consult system properties to get project/zone/cluster
124+
String projectId = requiredProperty("bigtable.projectID");
125+
String zone = requiredProperty("bigtable.zone");
126+
String clusterId = requiredProperty("bigtable.clusterID");
127127

128-
doHelloWorld(args[0], args[1], args[2]);
128+
doHelloWorld(projectId, zone, clusterId);
129+
}
130+
131+
private static String requiredProperty(String prop) {
132+
String value = System.getProperty(prop);
133+
if (value == null) {
134+
throw new IllegalArgumentException("Missing required system property: " + prop);
135+
}
136+
return value;
129137
}
130138

131139
}

0 commit comments

Comments
 (0)