Results 1 to 4 of 4
  1. #1
    eLancaster is offline Member
    Join Date
    Jan 2011
    Posts
    93
    Rep Power
    0

    Default Eclipse not underlining incorrect parts of the code

    I have a problem with Eclipse.

    Previously it would underline the incorrect parts of the code in red. if the code required a try catch - it would mark it as an error. Now it has stopped doing that for some reason - it doesn't even give an error while compiling although the exception is supposed to be checeked.

    Is there any way to fix this problem?

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

  3. #3
    eLancaster is offline Member
    Join Date
    Jan 2011
    Posts
    93
    Rep Power
    0

    Default

    Take a look at this - shouldn't there be a try catch with every declaration of a BufferedReader?
    I think there should.

    (Sorry for copying out such a long bit of code for a tiny problem)

    Java Code:
    public TicTacToeServer()
    	{	
    		try
    		{
    			ServerSocket TTTServer = new ServerSocket(8558);
    			System.out.printf("Log: Server Running at %s.\n",TTTServer.getLocalSocketAddress());
    			clientsList = new ArrayList<Socket>();
    			readersList = new ArrayList<BufferedReader>();
    			writersList = new ArrayList<PrintWriter>();
    			
    			while (true)
    			{
    				if(clientsList.size()==0)
    				{
    					Socket client = TTTServer.accept();
    					clientsList.add(client);
    					
    					
    					BufferedReader reader = new BufferedReader(new InputStreamReader(client.getInputStream()));
    					readersList.add(reader);
    					
    					PrintWriter writer = new PrintWriter(client.getOutputStream());
    					writersList.add(writer);
    					
    					System.out.printf("Log: Client %s has joined. No. of players = %d.\n",client.getLocalSocketAddress(),clientsList.size());
    					
    					Thread clientListMaintainer = new Thread( new ClientListMaintainer());
    					clientListMaintainer.setName("Client List Maintaining Thread");
    					clientListMaintainer.start();
    					
    				}
    				if(clientsList.size()==1)
    				{	
    					Socket client = TTTServer.accept();
    					clientsList.add(client);
    					
    					BufferedReader reader = new BufferedReader(new InputStreamReader(client.getInputStream()));
    					readersList.add(reader);
    					
    					PrintWriter writer = new PrintWriter(client.getOutputStream());
    					writersList.add(writer);
    					
    					System.out.printf("Log: Client %s has joined. No. of players = %d.\n",client.getLocalSocketAddress(),clientsList.size());						
    						
    					Thread clientMovesReceiver = new Thread(new OpponentMovesMessenger());
    					clientMovesReceiver.setName("Client Moves Receiver Thread");
    						
    					clientMovesReceiver.start();					
    				}
    				
    				if(clientsList.size()==2)
    				{
    					Socket client = TTTServer.accept();
    					PrintWriter writer = new PrintWriter(client.getOutputStream());
    					writer.println("r"); // r for rejected.
    					System.out.println("Log: Client rejected because Server was full.");
    				}
    			}
    		}catch(Exception e)
    		{
    			System.out.printf("Error: Unable to establish Server (%s).\n",e.toString());
    		}
    	}

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default

    All your class constructors and methods are within a try{} catch block that would catch any of their exceptions.
    Change the caught Exception to a specific exception for the Server communication stuff and see what happens.

Similar Threads

  1. several threads for different parts
    By Itun in forum AWT / Swing
    Replies: 2
    Last Post: 03-20-2011, 11:18 PM
  2. need help with few parts in java program please!
    By fezman1337 in forum JCreator
    Replies: 1
    Last Post: 11-22-2010, 05:26 PM
  3. Dubugger points to incorrect source code
    By gdias in forum Eclipse
    Replies: 0
    Last Post: 09-02-2008, 08:07 PM
  4. Selecting parts of an image
    By shaungoater in forum Java 2D
    Replies: 1
    Last Post: 12-15-2007, 10:06 PM
  5. Replies: 1
    Last Post: 04-26-2007, 03:52 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •