45 import sun.jvmstat.monitor.Monitor;
46 import sun.jvmstat.monitor.MonitoredHost;
47 import sun.jvmstat.monitor.MonitoredVm;
48 import sun.jvmstat.monitor.MonitorException;
49 import sun.jvmstat.monitor.VmIdentifier;
50
51 public class JCmd {
52 public static void main(String[] args) {
53 Arguments arg = null;
54 try {
55 arg = new Arguments(args);
56 } catch (IllegalArgumentException ex) {
57 System.err.println("Error parsing arguments: " + ex.getMessage()
58 + "\n");
59 Arguments.usage();
60 System.exit(1);
61 }
62
63 if (arg.isShowUsage()) {
64 Arguments.usage();
65 System.exit(1);
66 }
67
68 ProcessArgumentMatcher ap = null;
69 try {
70 ap = new ProcessArgumentMatcher(arg.getProcessString());
71 } catch (IllegalArgumentException iae) {
72 System.err.println("Invalid pid '" + arg.getProcessString() + "' specified");
73 System.exit(1);
74 }
75
76 if (arg.isListProcesses()) {
77 for (VirtualMachineDescriptor vmd : ap.getVirtualMachineDescriptors(/* include jcmd in listing */)) {
78 System.out.println(vmd.id() + " " + vmd.displayName());
79 }
80 System.exit(0);
81 }
82
83 Collection<String> pids = ap.getVirtualMachinePids(JCmd.class);
84
85 if (pids.isEmpty()) {
|
45 import sun.jvmstat.monitor.Monitor;
46 import sun.jvmstat.monitor.MonitoredHost;
47 import sun.jvmstat.monitor.MonitoredVm;
48 import sun.jvmstat.monitor.MonitorException;
49 import sun.jvmstat.monitor.VmIdentifier;
50
51 public class JCmd {
52 public static void main(String[] args) {
53 Arguments arg = null;
54 try {
55 arg = new Arguments(args);
56 } catch (IllegalArgumentException ex) {
57 System.err.println("Error parsing arguments: " + ex.getMessage()
58 + "\n");
59 Arguments.usage();
60 System.exit(1);
61 }
62
63 if (arg.isShowUsage()) {
64 Arguments.usage();
65 System.exit(0);
66 }
67
68 ProcessArgumentMatcher ap = null;
69 try {
70 ap = new ProcessArgumentMatcher(arg.getProcessString());
71 } catch (IllegalArgumentException iae) {
72 System.err.println("Invalid pid '" + arg.getProcessString() + "' specified");
73 System.exit(1);
74 }
75
76 if (arg.isListProcesses()) {
77 for (VirtualMachineDescriptor vmd : ap.getVirtualMachineDescriptors(/* include jcmd in listing */)) {
78 System.out.println(vmd.id() + " " + vmd.displayName());
79 }
80 System.exit(0);
81 }
82
83 Collection<String> pids = ap.getVirtualMachinePids(JCmd.class);
84
85 if (pids.isEmpty()) {
|