The error message says that the problem is in the accept() method of the MyServer class, at line 41 of MyServer.java. Let's see that method, and tell us which is line 41; the problem will probably be obvious.
OK, well, the error means that MyServerSocket is null -- i.e., the actual ServerSocket object is not being created. Where does it get initialized? Is the code that initializes it still going to run in your new configuration?
Is about the worst thing you can do, especially as a beginner. An exception is a message that tells you about something important that's happening; an empty catch block tears that message up without even looking at it. At the very least, you want to say
Changing the Exception type wont alter a thing - there is still a fundamental reason why your attempt to create an instance of ServerSocket is failing. in your catch block, try the following, and post the results it displays here for us to take a look at:
I believe what Henry means, is that you need to handle the exception if it is thrown. All you are doing is throwing the exception you are not actually saying what you want done incase of the exception.
init: deps-jar: Compiling 3 source files to C:\JavaProjects\OneClientTwoServer\build\classes
Note: Recompile with -Xlint:unchecked for details. compile: run: java.net.BindException: Address already in use: JVM_Bind Server 1 at java.net.PlainSocketImpl.socketBind(Native Method) at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:359) at java.net.ServerSocket.bind(ServerSocket.java:319) at java.net.ServerSocket.<init>(ServerSocket.java:185) at java.net.ServerSocket.<init>(ServerSocket.java:97) at oneclienttwoserver.ServerOne.<init>(ServerOne.java:22) at oneclienttwoserver.Main.main(Main.java:30) FAILED TO HOST ON 7500 BUILD SUCCESSFUL (total time: 0 seconds)
how it could use port 7500 when it generated exceptions always [ July 10, 2006: Message edited by: Medes Agri ]
author and iconoclast