public void run() {
						Initializer.sharedInstance().hideSplashScreen();
						if (System.getProperty("os.name").startsWith("Windows")) {
							JOptionPane.showMessageDialog(null, "Your current Java version is " + version + ". A newer version is needed.\nPlease go to http://java.com to get it.");
							try {
								Runtime.getRuntime().exec(new String[] { "explorer", "http://java.com" });
							}
							catch (Exception e) {
							}
						}
						else if (System.getProperty("os.name").startsWith("Linux")) {
							JOptionPane.showMessageDialog(null, "Your current Java version is " + version + ". A newer version is needed.\nPlease go to http://java.com to get it.");
						}
						else if (IS_MAC) {
							JOptionPane.showMessageDialog(null, "Your current Java version is " + version + ". A newer version is needed.\nPlease update it.");
						}
						System.exit(0);
					}
				});
			}
			catch (Exception e) {
				e.printStackTrace();
			}
		}
	}

	public static void setSystemProperty(String key, String value) {
		System.setProperty(key, value);
		if ("mw.cd.mode".equals(key))
			runOnCD = "true".equals(value);
		else if ("mw.jar.noupdate".equals(key))
			disableJarUpdate = "true".equals(value);
		else if ("mw.ui.nosetlaf".equals(key))
			disableSetLAF = "true".equals(value);
	}

	private static void setLocale() {
		userLocale = System.getProperty("mw.locale");
		if (userLocale == null)
			userLocale = Initializer.sharedInstance().getPreferences().get("Locale", null);
		if (userLocale != null) {
			if ("en_US".equals(userLocale))
				Locale.setDefault(Locale.US);
			else if ("zh_CN".equals(userLocale))
				Locale.setDefault(Locale.CHINA);
			else if ("zh_TW".equals(userLocale))
				Locale.setDefault(Locale.TAIWAN);
			else if (userLocale.startsWith("ru"))
				Locale.setDefault(new Locale("ru"));
			else if (userLocale.startsWith("es"))
				Locale.setDefault(new Locale("es"));
			else if (userLocale.startsWith("no"))
				Locale.setDefault(new Locale("no"));
			else if (userLocale.startsWith("he") || userLocale.startsWith("iw"))
				Locale.setDefault(new Locale("iw"));
		}
	}

	private static void preventMultipleInstances(String[] args) {
		try {
			serverSocket = ServerSocketFactory.getDefault().createServerSocket();
			serverSocket.bind(new InetSocketAddress(PORT_LAUNCH));
		}
		catch (Exception e) {
			boolean b = true;
			if (b) {
				Socket socket = null;
				PrintWriter out = null;
				try {
					socket = SocketFactory.getDefault().createSocket("localhost", PORT_LAUNCH);
					out = new PrintWriter(socket.getOutputStream(), true);
					String str = "";
					if (args != null && args.length >= 2) {
						str += args[1];
					}
					if (str.length() > 1) {
						out.println(str);
					}
					else {
						out.println(getStaticRoot() + "index.cml");
					}
				}
				catch (Exception e2) {
					e2.printStackTrace();
				}
				finally {
					if (out != null)
						out.close();
					if (socket != null) {
						try {
							socket.close();
						}
						catch (IOException ex) {
						}
					}
				}
			}
			else {
				try {
					EventQueue.invokeAndWait(new Runnable() {
						public void run() {
							JOptionPane.showMessageDialog(null, NAME + " is already running.");
						}
					});
				}
				catch (Exception ex) {
					ex.printStackTrace();
				}
			}
			System.exit(0);
		}
	}

	// customize the main window
	private static Modeler createModeler() {
		Modeler m = new Modeler();
		windowList.add(m);
		if ("false".equalsIgnoreCase(System.getProperty("mw.window.resizable"))) {
			m.setResizable(false);
		}
		if ("false".equalsIgnoreCase(System.getProperty("mw.window.menubar"))) {
			m.setJMenuBar(null);
		}
		if ("false".equalsIgnoreCase(System.getProperty("mw.window.toolbar"))) {
			m.getContentPane().remove(m.toolBar);
			m.editor.removeAllToolBars();
		}
		if ("false".equalsIgnoreCase(System.getProperty("mw.window.statusbar"))) {
			m.getContentPane().remove(m.statusBar);
		}
		String hp = System.getProperty("mw.homepage");
		if (hp != null)
			m.navigator.setHomePage(hp);
		int x = -1, y = -1, w = -1, h = -1;
		boolean parseOK = true;
		try {
			String s = System.getProperty("mw.window.width");
			if (s != null)
				w = Integer.parseInt(s);
			s = System.getProperty("mw.window.height");
			if (s != null)
				h = Integer.parseInt(s);
			s = System.getProperty("mw.window.left");
			if (s != null)
				x = Integer.parseInt(s);
			s = System.getProperty("mw.window.top");
			if (s != null)
				y = Integer.parseInt(s);
		}
		catch (NumberFormatException e) {
			e.printStackTrace();
			parseOK = false;
		}
		if (parseOK) {
			if (w > 0 || h > 0) {
				if (w == -1)
					w = m.editor.getPreferredSize().width;
				if (h == -1)
					h = m.editor.getPreferredSize().height;
				m.editor.setPreferredSize(new Dimension(w, h));
				m.statusBar.setPreferredSize(new Dimension(w, 20));
			}
			if (x >= 0 || y >= 0) {
				if (x == -1)
					x = m.getLocation().x;
				if (y == -1)
					y = m.getLocation().y;
				m.setLocation(x, y);
			}
		}
		return m;
	}

	private static void warnAboutJar() {
		String userDir = System.getProperty("user.dir");
		if (System.getProperty("os.name").startsWith("Windows"))
			userDir = userDir.replace('\\', '/');
		// if mw.jar is in the root directory, userDir="C:/"; otherwise, userDir="C:/folder"
		// note the former has an extra '/' that the latter does not have.
		if (userDir.endsWith("/"))
			userDir = userDir.substring(0, userDir.length() - 1);
		userDir = FileUtilities.httpEncode(userDir);
		ClassLoader cl = Thread.currentThread().getContextClassLoader();
		String resourceURL = cl.getResource("org/concord/modeler").toString();
		int i = resourceURL.indexOf(userDir);
		if (i != -1) {
			String s = resourceURL.substring(i + userDir.length() + 1);
			if (s.indexOf(".jar") == -1) { // likely in developer mode, disable security manager
				System.setProperty("mw.nosecurity", "true");
			}
			else {
				if (!s.startsWith("mw.jar") && !s.startsWith("dist/mw.jar")) {
					JOptionPane.showMessageDialog(Initializer.sharedInstance().getSplash(), "The file name must be exactly mw.jar in order to run in this mode.", "Security Error", JOptionPane.ERROR_MESSAGE);
					System.exit(-1);
				}
			}
		}
		else {
			if (resourceURL.indexOf("mw.jar") == -1) {
				JOptionPane.showMessageDialog(Initializer.sharedInstance().getSplash(), "You cannot run mw.jar directly from a web page. Save it\nto your computer and then double-click on it.", "Security Error", JOptionPane.ERROR_MESSAGE);
				System.exit(-1);
			}
		}
	}

	public static void main(String[] args) {

		directMW = true;

		// ModelerUtilities.printSystemProperties();

		checkMinimumJavaVersion();

		if (!"true".equalsIgnoreCase(System.getProperty("mw.newinstance"))) {
			// workaround to prevent the app from multiple instances
			preventMultipleInstances(args);
		}

		EventQueue.invokeLater(new Runnable() {
			public void run() {
				Initializer.sharedInstance().showSplashScreen();
			}
		});

		// feeding starting page and host flags
		if (args != null && args.length > 0) {
			hostIsLocal = "local".equalsIgnoreCase(args[0]);
			if (args.length > 1) {
				startingURL = args[1];
				if (startingURL != null) {
					if (System.getProperty("os.name").startsWith("Windows") && !FileUtilities.isRemote(startingURL)) {
						startingURL = startingURL.replace('/', '\\');
					}
					if (FileUtilities.isRelative(startingURL)) {
						startingURL = System.getProperty("user.dir") + System.getProperty("file.separator") + startingURL;
					}
				}
			}
		}

		mwLauncher = "yes".equals(System.getProperty("mw.launcher"));
		runOnCD = "true".equalsIgnoreCase(System.getProperty("mw.cd.mode"));

		// detect if the app is launched via webstart from its classloader. We use only two classloaders:
		// The SystemClassLoader and the JnlpClassLoader.
		ClassLoader cl = Thread.currentThread().getContextClassLoader();
		if (!cl.equals(ClassLoader.getSystemClassLoader()))
			launchedByJWS = true;

		// Workaround: Disable the default CookieHandler from Java Web Start, which prevents cookie from
		// being sent to the server through URLConnection.setRequestProperty
		if (launchedByJWS) {
			CookieHandler.setDefault(null);
		}

		// set locale if detected in the command line
		setLocale();

		if (IS_MAC) {
			System.setProperty("apple.laf.useScreenMenuBar", "false".equalsIgnoreCase(System.getProperty("mw.window.menubar")) ? "false" : "true");
			System.setProperty("apple.awt.brushMetalLook", "true");
		}

		if (hostIsLocal) {
			javax.swing.RepaintManager.setCurrentManager(new ThreadCheckingRepaintManager());
		}
		else {
			// warn user if the jar file is launched from untrusted path
			if (!launchedByJWS)
				warnAboutJar();
		}

		Debugger.print("Initialization");

		if (createUsingEDT) {

			EventQueue.invokeLater(new Runnable() {
				public void run() {
					// Initializer.sharedInstance().setMessage("Testing connection to the main MW server...");
					// ConnectionManager.sharedInstance().setWorkOffline(!ModelerUtilities.pingMwServer());
					Initializer.init();
					final Modeler m = createModeler();
					m.pack();
					m.setVisible(true);
					m.toFront();
					Initializer.sharedInstance().hideSplashScreen();
				}
			});

		}
		else {

			// loading worker thread
			final SwingWorker worker = new SwingWorker("Main loader", Thread.MIN_PRIORITY) {
				public Object construct() {
					Debugger.print("Starting main loader");
					// Initializer.sharedInstance().setMessage("Testing connection to the main MW server...");
					// ConnectionManager.sharedInstance().setWorkOffline(!ModelerUtilities.pingMwServer());
					Initializer.init();
					return createModeler();
				}

				public void finished() {
					Modeler m = (Modeler) get();
					Debugger.print("Modeler created");
					m.pack();
					m.editor.setToolBarOffset(-m.toolBar.getHeight());
					m.setVisible(true);
					Debugger.print("Modeler becomes visible");
					m.toFront();
					Debugger.print("Modeler brought to front");
					EventQueue.invokeLater(new Runnable() {
						public void run() {
							Initializer.sharedInstance().hideSplashScreen();
						}
					});
				}
			}