All Downloads are FREE. Search and download functionalities are using the official Maven repository.

fqlite.base.JARStarter Maven / Gradle / Ivy

package fqlite.base;

import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

/**
 * This class works as a dispatcher to run the correct main() function.
 * Note: FQLite does support 2 modes: command line interface (cli) and graphical (gui).
 * 
 * To run the FQLite from the command line you can use one of the  following options:
 *
 * $> java -jar  fqliteXXX.jar gui						: start program in gui mode
 * $> java -jar  fqliteXXX.jar nogui <database.db>       : starts the command line version
 * $> java -jar  fqliteXXX.jar cli <database.db>		    : starts the command line version
 * $> java -jar  fqliteXXX.jar                           : start program in gui mode
 * 
 * 
 * @author pawlaszc
 *
 */
public class JARStarter {

   private static Map> PROGRAM_MODES = new HashMap>();
	   
	    static{
	        PROGRAM_MODES.put("nogui", MAIN.class);
	        PROGRAM_MODES.put("cli", MAIN.class);
	    }
	
	public static void main(String[] args) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
		
			Class entryPoint = PROGRAM_MODES.get(args[0]);
			if(entryPoint==null){
					MAIN.printOptions();
					return;
			}
			
			final String[] argsCopy = args.length > 1  ? Arrays.copyOfRange(args, 1, args.length) : new String[0];
			entryPoint.getMethod("main", String[].class).invoke(null, (Object) argsCopy);
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy