import java.io.IOException;
import java.net.*;
import java.util.Timer;
import java.util.TimerTask;

public class chatServer {

	public static void main(String[] args) throws Exception {
		Database database = new Database();
		int port = 3000;
		int serverUpMinute = 3; 
		InetAddress address = InetAddress.getLocalHost();
		ServerSocket serverSocket = new ServerSocket(port);
		System.out.println("Chat server listening on " + address + ":" + port);
		Timer timer = new Timer();
		timer.schedule(new TimerTask(){
			  @Override
			  public void run() {
			     try {
					serverSocket.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			  }
			}, serverUpMinute*60*1000);
        Socket connectionSocket = null;

		while(true) { //run loop to wait for new connections
			connectionSocket = serverSocket.accept();
			new chatServerThread(connectionSocket, database).start();
		}
	}
}
@@ -9,93 +9,13 @@
 ava.
-io.IOException;%0Aimport java.net.*;%0Aimport java.util.Timer;%0Aimport java.util.TimerTask
+net.*
 ;%0A%0Ap
@@ -160,35 +160,8 @@
 00;%0A
-%09%09int serverUpMinute = 3; %0A
 %09%09In
@@ -262,16 +262,76 @@
 (port);%0A
+%09%09System.out.println(serverSocket.getLocalSocketAddress());%0A
 %09%09System
@@ -400,252 +400,8 @@
 t);%0A
-%09%09Timer timer = new Timer();%0A%09%09timer.schedule(new TimerTask()%7B%0A%09%09%09  @Override%0A%09%09%09  public void run() %7B%0A%09%09%09     try %7B%0A%09%09%09%09%09serverSocket.close();%0A%09%09%09%09%7D catch (IOException e) %7B%0A%09%09%09%09%09e.printStackTrace();%0A%09%09%09%09%7D%0A%09%09%09  %7D%0A%09%09%09%7D, serverUpMinute*60*1000);%0A
     

remove timer