void doMain ( String [ ] args , boolean throwOnError ) throws Exception { if ( args . length == 0 ) { usage ( throwOnError , "no arguments specified" ) ; return ; } else if ( args . length > 2 ) { usage ( throwOnError , "improper number of arguments:" + Arrays . toString ( args ) ) ; return ; } // check for --usage or --help if ( args . length == 1 && ( "--usage" . equals ( args [ 0 ] ) || "--help" . equals ( args [ 0 ] ) ) ) { usage ( throwOnError , null ) ; return ; } CommandLineJmxClient jmxClient ; if ( args [ 0 ] . indexOf ( ' ' ) >= 0 ) { jmxClient = new CommandLineJmxClient ( args [ 0 ] ) ; } else { String [ ] parts = args [ 0 ] . split ( ":" ) ; if ( parts . length != 2 ) { usage ( throwOnError , "argument should be in 'hostname:port' format, not: " + args [ 0 ] ) ; return ; } String hostName = parts [ 0 ] ; int port = 0 ; try { port = Integer . parseInt ( parts [ 1 ] ) ; } catch ( NumberFormatException e ) { usage ( throwOnError , "port number not in the right format: " + parts [ 1 ] ) ; return ; } jmxClient = new CommandLineJmxClient ( hostName , port ) ; } if ( args . length == 1 ) { jmxClient . runCommandLine ( ) ; } else if ( args . length == 2 ) { jmxClient . runBatchFile ( new File ( args [ 1 ] ) ) ; } }
This is package for testing purposes .