/*
 * #%L
 * ImageJ software for multidimensional image processing and analysis.
 * %%
 * Copyright (C) 2009 - 2013 Board of Regents of the University of
 * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck
 * Institute of Molecular Cell Biology and Genetics.
 * %%
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 * 
 * 1. Redistributions of source code must retain the above copyright notice,
 *    this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 *    this list of conditions and the following disclaimer in the documentation
 *    and/or other materials provided with the distribution.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 * 
 * The views and conclusions contained in the software and documentation are
 * those of the authors and should not be interpreted as representing official
 * policies, either expressed or implied, of any organization.
 * #L%
 */

package imagej;

import imagej.console.ConsoleService;
import imagej.ui.UIService;

/**
 * Launches ImageJ.
 * 
 * @author Curtis Rueden
 */
public final class Main {

	private Main() {
		// prevent instantiation of utility class
	}

	/**
	 * Launches a new instance of ImageJ.
	 * 
	 * @param args The arguments to pass to the new ImageJ instance.
	 * @return The context of the newly launched ImageJ instance.
	 */
	public static Context launch(final String... args) {
		final Context context = new Context();

		// parse command line arguments
		final ConsoleService consoleService =
			context.getService(ConsoleService.class);
		if (consoleService != null) consoleService.processArgs(args);

		// display the user interface
		final UIService uiService = context.getService(UIService.class);
		if (uiService != null) uiService.showUI();

		return context;
	}

	public static void main(final String... args) {
		launch(args);
	}

}

@@ -1840,75 +1840,8 @@
 j;%0A%0A
-import imagej.console.ConsoleService;%0Aimport imagej.ui.UIService;%0A%0A
 /**%0A
@@ -2184,23 +2184,22 @@
  static 
-Context
+ImageJ
  launch(
@@ -2234,37 +2234,30 @@
 nal 
-Context context = new Context
+ImageJ ij = new ImageJ
 ();%0A
@@ -2297,289 +2297,82 @@
 s%0A%09%09
-final ConsoleService consoleService =%0A%09%09%09context.getService(ConsoleService.class);%0A%09%09if (consoleService != null) consoleService.processArgs(args);%0A%0A%09%09// display the user interface%0A%09%09final UIService uiService = context.getService(UIService.class);%0A%09%09if (uiService != null) uiService
+ij.console().processArgs(args);%0A%0A%09%09// display the user interface%0A%09%09ij.ui()
 .sho
@@ -2388,23 +2388,18 @@
 %09return 
-context
+ij
 ;%0A%09%7D%0A%0A%09p

use ImageJ convenience class