src/main/java/de/vandermeer/execs/ExecS.java
public final int execute(String[] args){
		String arguments = StringUtils.join(args, ' ');
		StrTokenizer tokens = new StrTokenizer(arguments);

		String arg = tokens.nextToken();
		int ret = 0;

		if(arg==null || "-?".equals(arg) || "-h".equals(arg) || "--help".equals(arg)){
			//First help: no arguments or -? or --help -> print usage and exit(0)
			this.printUsage();
			return 0;
		}
		else if("-v".equals(arg) || "--version".equals(arg)){
			System.out.println(this.appName + " - " + ExecS.APP_VERSION);
			System.out.println();
		}
		else if("-l".equals(arg) || "--list".equals(arg)){
			//Second list: if -l or --list -> trigger search and exit(0)
			CF cf = new CF()
				.setJarFilter((ArrayUtils.contains(args, "-j"))?this.jarFilter:null)
				.setPkgFilter((ArrayUtils.contains(args, "-p"))?this.packageFilter:null);
			this.addAllApplications(cf.getSubclasses(ExecS_Application.class));
			this.printList();
			return 0;
		}
		else{
			Object svc = null;
			if(this.classmap.containsKey(arg)){
				try{
					svc = this.classmap.get(arg).newInstance();
				}
				catch(IllegalAccessException | InstantiationException iex){
					System.err.println(this.appName + ": tried to execute <" + args[0] + "> by registered name -> exception: " + iex.getMessage());
//					iex.printStackTrace();
					ret = -99;
				}
			}
			else{
				try{
					Class<?> c = Class.forName(arg);
					svc = c.newInstance();
				}
				catch(ClassNotFoundException | IllegalAccessException | InstantiationException ex){
					System.err.println(this.appName + ": tried to execute <" + args[0] + "> as class name -> exception: " + ex.getMessage());
//					ex.printStackTrace();
					ret = -99;
				}
			}
			ret = this.executeApplication(svc, args, arg);
		}

		if(ret==-99){
			//now we are in trouble, nothing we could do worked, so print that and quit
			System.err.println(this.appName + ": no application could be started and nothing else could be done, try '-?' or '--help' for help");
			System.err.println();
		}
		return ret;
	}
public final int execute(String[] args){
		String arguments = StringUtils.join(args, ' ');
		StrTokenizer tokens = new StrTokenizer(arguments);

		String arg = tokens.nextToken();
		int ret = 0;

		if(arg==null || "-?".equals(arg) || "-h".equals(arg) || "--help".equals(arg)){
			//First help: no arguments or -? or --help -> print usage and exit(0)
			this.printUsage();
			return 0;
		}
		else if("-v".equals(arg) || "--version".equals(arg)){
			System.out.println(this.appName + " - " + ExecS.APP_VERSION);
			System.out.println();
		}
		else if("-l".equals(arg) || "--list".equals(arg)){
			//Second list: if -l or --list -> trigger search and exit(0)
			CF cf = new CF()
				.setJarFilter((ArrayUtils.contains(args, "-j"))?this.jarFilter:null)
				.setPkgFilter((ArrayUtils.contains(args, "-p"))?this.packageFilter:null);
			this.addAllApplications(cf.getSubclasses(ExecS_Application.class));
			this.printList();
			return 0;
		}
		else{
			Object svc = null;
			if(this.classmap.containsKey(arg)){
				try{
					svc = this.classmap.get(arg).newInstance();
				}
				catch(IllegalAccessException | InstantiationException iex){
					System.err.println(this.appName + ": tried to execute <" + args[0] + "> by registered name -> exception: " + iex.getMessage());
//					iex.printStackTrace();
					ret = -99;
				}
			}
			else{
				try{
					Class<?> c = Class.forName(arg);
					svc = c.newInstance();
				}
				catch(ClassNotFoundException | IllegalAccessException | InstantiationException ex){
					System.err.println(this.appName + ": tried to execute <" + args[0] + "> as class name -> exception: " + ex.getMessage());
//					ex.printStackTrace();
					ret = -99;
				}
			}
			ret = this.executeApplication(svc, args, arg);
		}

		if(ret==-99){
			//now we are in trouble, nothing we could do worked, so print that and quit
			System.err.println(this.appName + ": no application could be started and nothing else could be done, try '-?' or '--help' for help");
			System.err.println();
		}
		return ret;
	}
public final int execute ( String [ ] args ) { String arguments = StringUtils . join ( args , ' ' ) ; StrTokenizer tokens = new StrTokenizer ( arguments ) ; String arg = tokens . nextToken ( ) ; int ret = 0 ; if ( arg == null || "-?" . equals ( arg ) || "-h" . equals ( arg ) || "--help" . equals ( arg ) ) { //First help: no arguments or -? or --help -> print usage and exit(0) this . printUsage ( ) ; return 0 ; } else if ( "-v" . equals ( arg ) || "--version" . equals ( arg ) ) { System . out . println ( this . appName + " - " + ExecS . APP_VERSION ) ; System . out . println ( ) ; } else if ( "-l" . equals ( arg ) || "--list" . equals ( arg ) ) { //Second list: if -l or --list -> trigger search and exit(0) CF cf = new CF ( ) . setJarFilter ( ( ArrayUtils . contains ( args , "-j" ) ) ? this . jarFilter : null ) . setPkgFilter ( ( ArrayUtils . contains ( args , "-p" ) ) ? this . packageFilter : null ) ; this . addAllApplications ( cf . getSubclasses ( ExecS_Application . class ) ) ; this . printList ( ) ; return 0 ; } else { Object svc = null ; if ( this . classmap . containsKey ( arg ) ) { try { svc = this . classmap . get ( arg ) . newInstance ( ) ; } catch ( IllegalAccessException | InstantiationException iex ) { System . err . println ( this . appName + ": tried to execute <" + args [ 0 ] + "> by registered name -> exception: " + iex . getMessage ( ) ) ; //					iex.printStackTrace(); ret = - 99 ; } } else { try { Class < ? > c = Class . forName ( arg ) ; svc = c . newInstance ( ) ; } catch ( ClassNotFoundException | IllegalAccessException | InstantiationException ex ) { System . err . println ( this . appName + ": tried to execute <" + args [ 0 ] + "> as class name -> exception: " + ex . getMessage ( ) ) ; //					ex.printStackTrace(); ret = - 99 ; } } ret = this . executeApplication ( svc , args , arg ) ; } if ( ret == - 99 ) { //now we are in trouble, nothing we could do worked, so print that and quit System . err . println ( this . appName + ": no application could be started and nothing else could be done, try '-?' or '--help' for help" ) ; System . err . println ( ) ; } return ret ; }
Main method
@param args command line arguments
@return 0 on success, -1 on error with message on STDERR
Main method