+ " while connecting to the jEdit server instance." + " This probably"); Log.log(Log.NOTICE,jEdit.class,"means that jEdit crashed" + " and/or exited abnormally the last" + " time it was run.");
+ " while connecting to the jEdit server instance."); Log.log(Log.NOTICE,jEdit.class,"This probably means that" + " jEdit crashed and/or exited abnormally"); Log.log(Log.NOTICE,jEdit.class,"the last time it was run.");
	public static void main(String[] args)	{		// for developers: run 'jedit 0' to get extensive logging		int level = Log.WARNING;		if(args.length >= 1)		{			String levelStr = args[0];			if(levelStr.length() == 1 && Character.isDigit(				levelStr.charAt(0)))			{				level = Integer.parseInt(levelStr);				args[0] = null;			}		}		// Parse command line		boolean endOpts = false;		boolean reuseView = false;		settingsDirectory = MiscUtilities.constructPath(			System.getProperty("user.home"),".jedit");		String portFile = "server";		boolean defaultSession = true;		session = "default";		boolean showSplash = true;		// don't freak because 'false' is the default. This flag		// is only checked when running in background mode		boolean showGUI = false;		for(int i = 0; i < args.length; i++)		{			String arg = args[i];			if(arg == null)				continue;			else if(arg.length() == 0)				args[i] = null;			else if(arg.startsWith("-") && !endOpts)			{				if(arg.equals("--"))					endOpts = true;				else if(arg.equals("-usage"))				{					version();					System.err.println();					usage();					System.exit(1);				}				else if(arg.equals("-version"))				{					version();					System.exit(1);				}				else if(arg.equals("-nosettings"))					settingsDirectory = null;				else if(arg.startsWith("-settings="))					settingsDirectory = arg.substring(10);				else if(arg.startsWith("-noserver"))					portFile = null;				else if(arg.startsWith("-server="))					portFile = arg.substring(8);				else if(arg.startsWith("-background"))					background = true;				else if(arg.startsWith("-gui"))					showGUI = true;				else if(arg.equals("-nosession"))					session = null;				else if(arg.startsWith("-session="))				{					session = arg.substring(9);					defaultSession = false;				}				else if(arg.equals("-nosplash"))					showSplash = false;				else if(arg.equals("-reuseview"))					reuseView = true;				else				{					System.err.println("Unknown option: "						+ arg);					usage();					System.exit(1);				}				args[i] = null;			}		}		if(settingsDirectory != null && portFile != null)			portFile = MiscUtilities.constructPath(settingsDirectory,portFile);		else			portFile = null;		if(session != null)			session = Sessions.createSessionFileName(session);		// Try connecting to another running jEdit instance		String userDir = System.getProperty("user.dir");		if(portFile != null && new File(portFile).exists())		{			int port, key;			try			{				BufferedReader in = new BufferedReader(new FileReader(portFile));				port = Integer.parseInt(in.readLine());				key = Integer.parseInt(in.readLine());				in.close();				Socket socket = new Socket(InetAddress.getLocalHost(),port);				Writer out = new OutputStreamWriter(socket.getOutputStream());				out.write(String.valueOf(key));				out.write('\n');				if(!defaultSession)				{					if(session != null)						out.write("session=" + session + "\n");					else						out.write("nosession\n");				}				if(reuseView)					out.write("reuseview\n");				out.write("parent=" + userDir + "\n");				out.write("--\n");				for(int i = 0; i < args.length; i++)				{					if(args[i] != null)					{						out.write(args[i]);						out.write('\n');					}				}				out.close();				System.exit(0);			}			catch(Exception e)			{				// ok, this one seems to confuse newbies				// endlessly, so log it as NOTICE, not				// ERROR				Log.log(Log.NOTICE,jEdit.class,"An error occurred"					+ " while connecting to the jEdit server instance."					+ " This probably");				Log.log(Log.NOTICE,jEdit.class,"means that jEdit crashed"					+ " and/or exited abnormally the last"					+ " time it was run.");				Log.log(Log.NOTICE,jEdit.class,"If you don't"					+ " know what this means, don't worry.");				Log.log(Log.NOTICE,jEdit.class,e);			}		}		// Show the kool splash screen		if(showSplash)			GUIUtilities.showSplashScreen();		// Initialize activity log and settings directory		Writer stream;		if(settingsDirectory != null)		{			File _settingsDirectory = new File(settingsDirectory);			if(!_settingsDirectory.exists())				_settingsDirectory.mkdirs();			File _macrosDirectory = new File(settingsDirectory,"macros");			if(!_macrosDirectory.exists())				_macrosDirectory.mkdir();			File _sessionsDirectory = new File(settingsDirectory,"sessions");			if(!_sessionsDirectory.exists())				_sessionsDirectory.mkdir();			String logPath = MiscUtilities.constructPath(				settingsDirectory,"activity.log");			try			{				stream = new BufferedWriter(new FileWriter(logPath));			}			catch(Exception e)			{				e.printStackTrace();				stream = null;			}		}		else		{			stream = null;		}		Log.init(true,level,stream);		Log.log(Log.NOTICE,jEdit.class,"jEdit version " + getVersion());		Log.log(Log.MESSAGE,jEdit.class,"Settings directory is "			+ settingsDirectory);		// Get things rolling		initMisc();		initSystemProperties();		GUIUtilities.advanceSplashProgress();		initPlugins();		GUIUtilities.advanceSplashProgress();		initUserProperties();		if(settingsDirectory != null)		{			File history = new File(MiscUtilities.constructPath(				settingsDirectory,"history"));			if(history.exists())				historyModTime = history.lastModified();			HistoryModel.loadHistory(history);		}		Abbrevs.load();		GUIUtilities.advanceSplashProgress();		// Buffer sort		sortBuffers = getBooleanProperty("sortBuffers");		sortByName = getBooleanProperty("sortByName");		propertiesChanged();		initPLAF();		initRecent();		SearchAndReplace.load();		initActions();		initModes();		Macros.loadMacros();		FavoritesVFS.loadFavorites();		GUIUtilities.advanceSplashProgress();		// Start plugins		for(int i = 0; i < jars.size(); i++)		{			((EditPlugin.JAR)jars.elementAt(i)).getClassLoader()				.loadAllPlugins();		}		GUIUtilities.advanceSplashProgress();		// Preload menu and tool bar models		GUIUtilities.loadMenuBarModel("view.mbar");		GUIUtilities.loadMenuModel("view.context");		GUIUtilities.loadMenuModel("gutter.context");		if(getBooleanProperty("view.showToolbar"))			GUIUtilities.loadToolBarModel("view.toolbar");		GUIUtilities.advanceSplashProgress();		// Start server		if(portFile != null)			server = new EditServer(portFile);		else		{			if(background)			{				background = false;				System.err.println("You cannot specify both the"					+ " -background and -noserver switches");			}		}		Buffer buffer = openFiles(userDir,args);		if(bufferCount == 0)		{			// don't load default session when in background mode			if(defaultSession)			{				if(!background && session != null					&& getBooleanProperty("saveDesktop"))					buffer = Sessions.loadSession(session,true);			}			else				buffer = Sessions.loadSession(session,true);		}		// Create the view and hide the splash screen.		final boolean _showGUI = showGUI;		final Buffer _buffer = buffer;		GUIUtilities.advanceSplashProgress();		SwingUtilities.invokeLater(new Runnable() {			public void run()			{				EditBus.send(new EditorStarted(null));				// If no files to open were specified in				// background mode, don't create a view.				if(background && !_showGUI)				{					if(bufferCount != 0)						newView(null,_buffer);				}				else				{					if(bufferCount == 0)						newFile(null);					newView(null,_buffer);				}				GUIUtilities.hideSplashScreen();				Log.log(Log.MESSAGE,jEdit.class,"Startup "					+ "complete");				// Start I/O thread				VFSManager.start();			}		});	}