public static void main(String[] args){        
        // create/confiugre the context
        Context context  = null;
        File libDir = Clamshell.Runtime.getLibDir();
        File pluginsDir = Clamshell.Runtime.getPluginsDir();
        
        // register shutdown hook
        
        
        // Create/get Context, if something goes wrong, exit.
        try{
            context = Clamshell.Runtime.getContext();
        }catch(RuntimeException ex){
            System.out.printf("%nUnable to start Clamshell:%n%s.%n", ex.getMessage());
            System.exit(1);
        }
                
        // only continue if plugins are found
        if(!libDir.exists()){
            System.out.printf("%nLib directory not found. ClamShell-Cli will exit.%n", 
                libDir.getAbsolutePath());
            System.exit(1);
        }
        
        // load classes from lib directory
        ClassLoader libDirCl = null;
        try{
            ClassLoader parent = Thread.currentThread().getContextClassLoader();
            libDirCl = Clamshell.ClassManager.getClassLoaderFromFiles(
                new File[]{libDir}, 
                Configurator.JARFILE_PATTERN,
                parent
            );
            Thread.currentThread().setContextClassLoader(libDirCl);
        }catch(Exception ex){
            System.out.printf("%nUnable to load classes from lib directory %s:%n%s.", libDir, ex.getMessage());
        }finally{
            if (libDirCl == null){
                System.out.printf("%nUnable to load classes from lib directory %s:%n.", libDir);
            }
        }
        
        // load Plugins classloader
        ClassLoader pluginsCl = null;
        try{
            pluginsCl = Clamshell.ClassManager.getClassLoaderFromFiles(
                new File[]{pluginsDir}, 
                Configurator.JARFILE_PATTERN,
                Thread.currentThread().getContextClassLoader()
            );
            context.putValue(Context.KEY_CLASS_LOADER, pluginsCl);
        }catch(Exception ex){
            System.out.printf("%nUnable to load Plugin classes %s:%n%s.", pluginsDir, ex.getMessage());
        }finally{
            if(pluginsCl == null){
                System.out.printf("%nUnable to load Plugin classes in directory %s:%n.", libDir);
            }
        }
        
        // load plugins
        List<Plugin> plugins =  Clamshell.Runtime.loadServicePlugins(Plugin.class, pluginsCl);
        if(plugins.isEmpty()){
            System.out.printf ("%nNo Plugin classes found in plugins directory, exiting...%n");
            System.exit(1);
        }
        context.putValue(Context.KEY_PLUGINS, plugins);
        List<Shell> shells = context.getPluginsByType(Shell.class);
                
        // Look for default Shell to launch.
        if(shells.size() > 0){
            Shell shell = shells.get(0);
            try{
                context.putValue(Context.KEY_SHELL_COMPONENT, shell);
                shell.plug(context);
            }catch(Exception ex){
                System.out.println("Something went wrong while bootstrapping the Shell:");
                ex.printStackTrace(System.err);
                System.exit(1);
            }
            
            // before launch, register shutdown handler
            Runtime.getRuntime().addShutdownHook(new ShutdownHook(context));

            
        }else{
            System.out.printf (
                "%nNo Shell component found in plugins directory." +
                "%nA Shell is required to continue bootstrapping sequence." +
                "%nExiting now."
            );
            System.exit(1);
        }
    }