I am trying to set up a Server
for a Worms-like game made in Java (to allow Multiplayer and in-game chat) but I have this specific problem.
I have tried changing the import, but it didn't resolve the issue.
Screenshot here : https://i.stack.imgur.com/cAlQK.png
package Server;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.util.HashSet;
import java.util.logging.Handler;
public class Server {
private static final int PORT = 9001;
private static HashSet<String> names = new HashSet<String>();
private static HashSet<PrintWriter> writers =
new HashSet<PrintWriter>();
public static void main(String[] args) throws Exception {
System.out.println("The chat server is running.");
try(ServerSocket listener = new ServerSocket(PORT)) {
while (true) {
new Thread(new Handler(listener.accept())).start();
}
}
}
}