JCommander
    static class Arguments {
 
        @Parameter(names = {"--host"}, required = true, description = "zookeeper host")
        String host;
 
        @Parameter(names = {"--threadCount"}, description = "how many threads will be used by producer")
        int threadCount = 4;
    }
 
    public static void main(String[] cmdArgs) throws Exception{
        Arguments args = new Arguments();
        JCommander jCommander = new JCommander(args);
        try {
            jCommander.parse(cmdArgs);
        }catch (ParameterException ex) {
            log.error(ex.getMessage(), ex);
            jCommander.usage();
            throw ex;
        }
        System.out.println(args.host);
   }
Пока не указано иное, содержимое этой страницы распространяется по лицензии Creative Commons Attribution-ShareAlike 3.0 License