portFile = new File(System.getProperty("user.home"), ".jedit-server"); jEditHome = System.getProperty("jedit.home"); if(jEditHome == null) { String classpath = System .getProperty("java.class.path"); int index = classpath.toLowerCase() .indexOf("jedit.jar"); if(index > 0) { int start = classpath.lastIndexOf(File .pathSeparator,index) + 1; jEditHome = classpath.substring(start, index - 1); } else jEditHome = System.getProperty("user.dir"); }
String userHome = System.getProperty("user.home"); String userDir = System.getProperty("user.dir"); usrProps = System.getProperty("user.home") + File.separator + ".jedit-props"; portFile = new File(userHome,".jedit-server"); desktopFile = new File(userHome,".jedit-desktop"); boolean showSplash = true;
	public static void main(String[] args)	{		boolean endOpts = false;		boolean noUsrProps = false;		boolean readOnly = false;		portFile = new File(System.getProperty("user.home"),			".jedit-server");		jEditHome = System.getProperty("jedit.home");		if(jEditHome == null)		{			String classpath = System				.getProperty("java.class.path");			int index = classpath.toLowerCase()				.indexOf("jedit.jar");			if(index > 0)			{				int start = classpath.lastIndexOf(File					.pathSeparator,index) + 1;				jEditHome = classpath.substring(start,					index - 1);			}			else				jEditHome = System.getProperty("user.dir");		}		for(int i = 0; i < args.length; i++)		{			String arg = args[i];			if(arg.startsWith("-") && !endOpts)			{				if(arg.equals("--"))					endOpts = true;				else if(arg.equals("-usage"))					usage();				else if(arg.equals("-version"))					version();				else if(arg.equals("-nousrprops"))					noUsrProps = true;				else if(arg.equals("-noserver"))					portFile = null;				else if(arg.startsWith("-portfile="))					portFile = new File(arg.substring(10));				else if(arg.equals("-readonly"))					readOnly = true;				else				{					System.err.println("Unknown option: "						+ arg);					usage();				}				args[i] = null;			}		}		if(portFile != null && portFile.exists())		{			try			{				BufferedReader in = new BufferedReader(					new FileReader(portFile));				Socket socket = new Socket("localhost",					Integer.parseInt(in.readLine()));				DataOutputStream out = new DataOutputStream(					socket.getOutputStream());				out.writeBytes(in.readLine());				out.write('\n');				if(readOnly)					out.writeBytes("-readonly\n");				out.writeBytes("-cwd=" + System					.getProperty("user.dir") + "\n");				boolean opened = false;				for(int i = 0; i < args.length; i++)				{					if(args[i] == null)						continue;					out.writeBytes(args[i]);					out.write('\n');					opened = true;				}				if(!opened)					out.write('\n');				socket.close();				in.close();				System.exit(0);				return;			}			catch(Exception e)			{				System.out.println("Stale port file deleted");				portFile.delete();			}		}		props.loadSystemProps();		try		{			cmds.initMode("autoindent");			cmds.initMode("bat");			cmds.initMode("c");			cmds.initMode("html");			cmds.initMode("java_mode");			cmds.initMode("makefile");			cmds.initMode("sh");			cmds.initMode("tex");		}		catch(Exception e)		{			e.printStackTrace();			jEdit.error(null,"loadmodeerr",null);		}		cmds.loadPlugins(jEditHome + File.separator + "jars");		cmds.loadPlugins(System.getProperty("user.home") +			File.separator + ".jedit-jars");		if(!noUsrProps)			props.loadUserProps();			propertiesChanged();		String userDir = System.getProperty("user.dir");		boolean opened = false;		Buffer buffer = null;		for(int i = 0; i < args.length; i++)		{			if(args[i] == null)				continue;			opened = true;			buffer = buffers.openFile(null,userDir,args[i],				readOnly,false);		}		if(!opened)			buffer = buffers.newFile(null);		try		{			cmds.execHook(buffer,buffers.newView(buffer),				"post_startup");		}		catch(Exception e)		{			e.printStackTrace();			Object[] _args = { e.toString() };			jEdit.error(null,"execcmderr",_args);		}	}