public static void main ( String [ ] args ) throws IOException { Properties properties = new Properties ( ) ; for ( int i = 0 ; i < args . length ; i ++ ) { String name = args [ i ] ; if ( name . startsWith ( "-" ) && name . length ( ) > 1 && ++ i < args . length ) { name = name . substring ( 1 ) ; if ( "properties" . equals ( name ) ) { try ( InputStream propsStream = Bootstrapper . class . getClassLoader ( ) . getResourceAsStream ( name ) ) { if ( propsStream == null ) throw new IOException ( "Could not read bootstrapper properties" ) ; Properties props = new Properties ( ) ; props . load ( propsStream ) ; props . putAll ( properties ) ; properties = props ; } } else { properties . put ( name , args [ i ] ) ; } } else { System . err . println ( "invalid argument: " + name ) ; System . err . println ( getUsage ( ) ) ; System . exit ( 1 ) ; } } String invalid = joinList ( listInvalidKeys ( properties ) ) ; if ( invalid != null && invalid . length ( ) > 0 ) { System . err . println ( "invalid arguments: " + invalid ) ; System . err . println ( getUsage ( ) ) ; System . exit ( 1 ) ; } // TODO: catch invalid argument exceptions and provide feedback new Bootstrapper ( ) . makeServer ( properties ) ; System . out . println ( "Created " + properties . getProperty ( "restserver" ) + " server on " + properties . getProperty ( "restport" ) + " port for " + properties . getProperty ( "restdb" ) + " database" ) ; }
Command - line invocation .