< prev index next >
src/jdk.jstatd/share/classes/sun/tools/jstatd/Jstatd.java
Print this page
rev 47855 : 8189102: All tools should support -?, -h and --help
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
@@ -45,11 +45,12 @@
private static Registry registry;
private static int port = -1;
private static boolean startRegistry = true;
private static void printUsage() {
- System.err.println("usage: jstatd [-nr] [-p port] [-n rminame]");
+ System.err.println("usage: jstatd [-nr] [-p port] [-n rminame]\n" +
+ " jstatd -?|-h|--help");
}
static void bind(String name, RemoteHostImpl remoteHost)
throws RemoteException, MalformedURLException, Exception {
@@ -76,11 +77,16 @@
int argc = 0;
for ( ; (argc < args.length) && (args[argc].startsWith("-")); argc++) {
String arg = args[argc];
- if (arg.compareTo("-nr") == 0) {
+ if (arg.compareTo("-?") == 0 ||
+ arg.compareTo("-h") == 0 ||
+ arg.compareTo("--help") == 0) {
+ printUsage();
+ System.exit(0);
+ } else if (arg.compareTo("-nr") == 0) {
startRegistry = false;
} else if (arg.startsWith("-p")) {
if (arg.compareTo("-p") != 0) {
port = Integer.parseInt(arg.substring(2));
} else {
< prev index next >