else if(arg.equals("-bshclient")) client = true;
else if(arg.startsWith("-run=")) scriptFile = arg.substring(5);
	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 newView = false; // only used by EditServer client		boolean client = false; // only used by EditServer client		settingsDirectory = MiscUtilities.constructPath(			System.getProperty("user.home"),".jedit");		String portFile = "server";		boolean restore = true;		boolean noStartupScripts = 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.equals("-server"))					portFile = "server";				else if(arg.startsWith("-server="))					portFile = arg.substring(8);				else if(arg.startsWith("-background"))					background = true;				else if(arg.equals("-norestore"))					restore = false;				else if(arg.equals("-nostartupscripts"))					noStartupScripts = true;				else if(arg.equals("-newview"))					newView = true;				else if(arg.equals("-bshclient"))					client = 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;		Log.init(true,level);		// Try connecting to another running jEdit instance		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.getByName("127.0.0.1"),port);				Writer out = new OutputStreamWriter(socket.getOutputStream(),"UTF8");				out.write(String.valueOf(key));				out.write('\n');				if(client)				{					// read script from standard input, in UTF8!!					in = new BufferedReader(new InputStreamReader(						System.in,"UTF8"));					char[] buf = new char[1024];					int count;					while((count = in.read(buf,0,buf.length)) != -1)					{						out.write(buf,0,count);					}					in.close();				}				else				{					String script = makeServerScript(restore,newView,args);					out.write(script);				}				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.");				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.");				Log.log(Log.NOTICE,jEdit.class,"If you don't"					+ " know what this means, don't worry.");				Log.log(Log.NOTICE,jEdit.class,e);			}		}		else if(client)		{			Log.log(Log.ERROR,jEdit.class,"The -bshclient switch"				+ " can only be used if an edit server is");			Log.log(Log.ERROR,jEdit.class,"already running.");			System.exit(1);		}		// MacOS X GUI hacks		if(System.getProperty("os.name").indexOf("MacOS X") != -1)		{			// put the menu bar at the top of the screen, as opposed to			// inside the jEdit window			System.getProperties().put("com.apple.macos.useScreenMenuBar","true");		}		// Initialize activity log and settings directory		boolean showSplash = true;		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();			String logPath = MiscUtilities.constructPath(				settingsDirectory,"activity.log");			try			{				stream = new BufferedWriter(new FileWriter(logPath));			}			catch(Exception e)			{				e.printStackTrace();				stream = null;			}			// don't show splash screen if there is a file named			// 'nosplash' in the settings directory			if(new File(settingsDirectory,"nosplash").exists())				showSplash = false;		}		else		{			stream = null;		}		// Show the kool splash screen		if(showSplash)			GUIUtilities.showSplashScreen();		Log.setLogWriter(stream);		Log.log(Log.NOTICE,jEdit.class,"jEdit version " + getVersion());		Log.log(Log.MESSAGE,jEdit.class,"Settings directory is "			+ settingsDirectory);		// Initialize server		if(portFile != null)		{			server = new EditServer(portFile);			if(!server.isOK())				server = null;		}		else		{			if(background)			{				background = false;				System.err.println("You cannot specify both the"					+ " -background and -noserver switches");			}		}		// Get things rolling		initMisc();		initSystemProperties();		BeanShell.init();		GUIUtilities.advanceSplashProgress();		if(jEditHome != null)			initSiteProperties();		initUserProperties();		initActions();		initPlugins();		if(settingsDirectory != null)		{			File history = new File(MiscUtilities.constructPath(				settingsDirectory,"history"));			if(history.exists())				historyModTime = history.lastModified();			HistoryModel.loadHistory(history);			File recent = new File(MiscUtilities.constructPath(				settingsDirectory,"recent.xml"));			if(recent.exists())				recentModTime = recent.lastModified();			BufferHistory.load(recent);		}		Abbrevs.load();		GUIUtilities.advanceSplashProgress();		// Buffer sort		sortBuffers = getBooleanProperty("sortBuffers");		sortByName = getBooleanProperty("sortByName");		initPLAF();		reloadModes();		GUIUtilities.advanceSplashProgress();		SearchAndReplace.load();		FavoritesVFS.loadFavorites();		Macros.loadMacros();		GUIUtilities.advanceSplashProgress();		// Start plugins		for(int i = 0; i < jars.size(); i++)		{			((EditPlugin.JAR)jars.elementAt(i)).getClassLoader()				.startAllPlugins();		}		// Run startup scripts, after plugins, proeprties, etc		// are loaded		if(!noStartupScripts && jEditHome != null)		{			String path = MiscUtilities.constructPath(jEditHome,"startup");			File file = new File(path);			if(file.exists())				runStartupScripts(file);		}		if(!noStartupScripts && settingsDirectory != null)		{			String path = MiscUtilities.constructPath(settingsDirectory,"startup");			File file = new File(path);			if(!file.exists())				file.mkdirs();			else				runStartupScripts(file);		}		// Must be after plugins are started!!!		propertiesChanged();		GUIUtilities.advanceSplashProgress();		Buffer buffer = openFiles(null,System.getProperty("user.dir"),args);		String splitConfig = null;		if(restore && settingsDirectory != null			&& jEdit.getBooleanProperty("restore")			&& (bufferCount == 0 || jEdit.getBooleanProperty("restore.cli")))		{			splitConfig = restoreOpenFiles();		}		// Create the view and hide the splash screen.		final Buffer _buffer = buffer;		final String _splitConfig = splitConfig;		GUIUtilities.advanceSplashProgress();		SwingUtilities.invokeLater(new Runnable() {			public void run()			{				if(bufferCount == 0)					newFile(null);				EditBus.send(new EditorStarted(null));				View view;				if(_buffer != null)					view = newView(null,_buffer);				else					view = newView(null,_splitConfig);				// show tip of the day				if(jEdit.getBooleanProperty("firstTime"))					new HelpViewer("welcome.html");				else if(jEdit.getBooleanProperty("tip.show"))					new TipOfTheDay(view);				setBooleanProperty("firstTime",false);				// Start I/O threads				VFSManager.start();				// Start edit server				if(server != null)					server.start();				GUIUtilities.hideSplashScreen();				Log.log(Log.MESSAGE,jEdit.class,"Startup "					+ "complete");			}		});	}