final ConsoleManager conMgr = (ConsoleManager) InitialNaming .lookup(ConsoleManager.NAME);
final ShellManager sm = InitialNaming.lookup(ShellManager.NAME); final ConsoleManager conMgr = sm.getCurrentShell().getConsole().getManager();
    public static void main(String[] args) throws NameNotFoundException,            ShellException {        final ConsoleManager conMgr = (ConsoleManager) InitialNaming                .lookup(ConsoleManager.NAME);                boolean listConsoles = false;        boolean newConsole = false;        boolean isolateNewConsole = false;                System.out.print("args: ");        for (String arg : args) {            System.out.print(arg);            if (arg.equals("-l")) {                listConsoles = true;            } else if (arg.equals("-n")) {                newConsole = true;            } else if (arg.equals("-i")) {                isolateNewConsole = true;            }        }        System.out.println();                if (listConsoles) {            final Set<String> consoleNames = conMgr.getConsoleNames();            System.out.println("Nr. of registered consoles: "                    + consoleNames.size());            for (String name : consoleNames) {                final Console console = conMgr.getConsole(name);                System.out.println("      - "                        + name                        + " ACCEL:"                        + KeyEvent.getKeyText(console                                .getAcceleratorKeyCode()));            }        } else if (newConsole) {            if (isolateNewConsole) {                try {                    Isolate newIsolate = new Isolate(ConsoleCommand.class.getName(), new String[] { "-n" });                    newIsolate.start();                } catch (IsolateStartupException ex) {                    System.out.println("Failed to start new isolated console");                    ex.printStackTrace(System.err);                }            } else {                final TextConsole console = (TextConsole) conMgr.createConsole(                        null, ConsoleManager.CreateOptions.TEXT                        | ConsoleManager.CreateOptions.SCROLLABLE);                CommandShell commandShell = new CommandShell(console);                new Thread(commandShell).start();                                System.out.println("Console created with name:"                        + console.getConsoleName());            }        } else {            System.out.println("test RawTextConsole");            final TextConsole console = (TextConsole) conMgr.createConsole(                    null, ConsoleManager.CreateOptions.TEXT);            conMgr.registerConsole(console);            conMgr.focus(console);            console.clear();        }    }