public static void main(String[] args) {
		
		if(args.length >= 1 && !args[0].equals("${ServiceName}")) {
			ServiceName = args[0];
		} else {
			ServiceName = DEFAULT_SERVICE_NAME;
		}
		
		Registry reg = establishRegistry(); 

		try {
			MyFD myFD = new MyFD();
			reg.rebind(ServiceName, myFD);       // Bind object
			
			System.out.println(new Date() + " Registered with registry");
		} catch (RemoteException e) {
			System.out.println(new Date() + " Error: " + e);
		} // try
		
		NetworkInterface ni;
		try {
			ni = NetworkInterface.getByName("net4");
			
			Node me = new Node();
			me.setIP(ni.getInetAddresses().nextElement().getHostAddress());
			me.setPort(port);
			me.setServiceName(ServiceName);
			
			fd.setMe(me);
			fd.setFirst(me);
			fd.setSecond(me);
			fd.setThird(me);
			fd.setPulse(me);
			
			System.out.println(new Date() + " created me {");
			System.out.println(new Date() + " \t IP: " + fd.getMe().getIP());
			System.out.println(new Date() + " \t Port: " + fd.getMe().getPort());
			System.out.println(new Date() + " \t ServiceName: " + fd.getMe().getServiceName());
			System.out.println(new Date() + " }");
		} catch (SocketException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		
		if (args.length >= 1 && !args[1].equals("${NodeIP:Port}")) {
			ConnectionURI = args[1];
						
			if (args.length == 3 && !args[2].equals("${ContactServiceName}"))
				ContactServiceName = args[2];
					
			try {
				JoinThread jt = new JoinThread(ConnectionURI, ServiceName, fd);
				jt.start();
				jt.join();
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			
			timer.schedule(timeoutTask, TIMEOUT);
			
		} else {
			System.out.println(new Date() + " I'm the first one");
		}
		
		Thread generator = new PulseGenerator(fd);
    	generator.start();
	}