public static void main(String[] args) throws FileNotFoundException {
		String masterName = "masterServer";
		String masterAdd = args[0];
		int masterPort = new Integer(args[1]);
		String dir = args[2];
		File metaData = new File("metaData.txt");
		File repServers = new File("repServers.txt");
		TreeMap<String, ReplicaLoc> nameToLocMap = new TreeMap<String, ReplicaLoc>();

		Scanner scanner = new Scanner(repServers);

		while (scanner.hasNext()) {
			String repName = scanner.next(), repAddress = scanner.next();
			int repPort = scanner.nextInt();
			nameToLocMap.put(repName, new ReplicaLoc(repAddress, repName,
					repPort));
		}
		scanner.close();

		try {
			Registry registry = null;
			try {
				registry = LocateRegistry.createRegistry(masterPort);
			} catch (Exception e) {
				registry = LocateRegistry.getRegistry(masterPort);
			}

			MasterServerImpl masterServerObj = new MasterServerImpl(metaData,
					nameToLocMap);
			MasterServerClientInterface masterServerStub = (MasterServerClientInterface) UnicastRemoteObject
					.exportObject(masterServerObj, 0);
			registry.bind(masterName, masterServerStub);
		} catch (Exception e) {
			e.printStackTrace();
		}

		// pkill -f 'java.*ReplicaServerImpl'
		try {
			for (ReplicaLoc repLoc : nameToLocMap.values()) {
				Process p = Runtime.getRuntime()
						.exec("ssh " + repLoc.getHost());
				PrintStream out = new PrintStream(p.getOutputStream(), true);
				StreamReader ls = new StreamReader(p.getInputStream(), false);
				StreamReader es = new StreamReader(p.getErrorStream(), true);

				Thread t = new Thread(ls);
				Thread t2 = new Thread(es);
				t.start();
				t2.start();

				out.println("cd workspace/ReplicatedFS/src");
				out.println("javac API/ReplicaServerClientInterface.java Impl/ReplicaServerImpl.java");
				// args: name dir port masterName masterAddress masterPort
				out.println("java  Impl/ReplicaServerImpl " + repLoc.getName()
						+ " " + dir + " " + repLoc.getPort() + " " + masterName
						+ " " + masterAdd + " " + masterPort);
				out.println("exit");

				// t.join();
				// t2.join();
			}
		} catch (Exception e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
	}