Results 1 to 6 of 6
Like Tree1Likes
  • 1 Post By Norm

Thread: Weird error(connecting to a ServerSocket)

  1. #1
    Pojahn_M's Avatar
    Pojahn_M is offline Senior Member
    Join Date
    Mar 2011
    Location
    Sweden
    Posts
    197
    Rep Power
    4

    Default Weird error(connecting to a ServerSocket)

    Line 12 is connecting to a ServerSocket. If am trying to connect to a server that don't exist, I get weird error.
    If the server do not exist, ConnectException is thrown, however the catch block is not picking it up. And the program is frozen. How is that possible?

    Java Code:
    		getnewFiles.addActionListener(new ActionListener ()
    		{
    			@Override
    			public void actionPerformed(ActionEvent e) 
    			{
    				disableAll ();
    				
    				int updates;
    				
    				try 
    				{
    					updates = client.checkNews ();
    				}
    				catch (ClassNotFoundException | IOException e1) 
    				{
    					processFailed (e1);
    					enableAll ();
    					return;
    				}
    				...
    				enableAll ();
    			}
    		});

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,562
    Rep Power
    25

    Default Re: Weird error(connecting to a ServerSocket)

    Change the catch to be for Exception and see what happens.
    Also add a call to printStackTrace in the catch block to get more details.

    Does the posted code compile? I've never seen a catch like on line 14

    Are you using an IDE that ignores compiler errors?
    Last edited by Norm; 02-11-2012 at 11:35 PM.
    Pojahn_M likes this.

  3. #3
    Pojahn_M's Avatar
    Pojahn_M is offline Senior Member
    Join Date
    Mar 2011
    Location
    Sweden
    Posts
    197
    Rep Power
    4

    Default Re: Weird error(connecting to a ServerSocket)

    Changing the catch to Exception solved the problem. Its a bit odd, because the API never mention this.
    Line 14 is valid btw.

  4. #4
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,562
    Rep Power
    25

    Default Re: Weird error(connecting to a ServerSocket)

    What version of the javac compiler are you using?

  5. #5
    Pojahn_M's Avatar
    Pojahn_M is offline Senior Member
    Join Date
    Mar 2011
    Location
    Sweden
    Posts
    197
    Rep Power
    4

    Default Re: Weird error(connecting to a ServerSocket)

    JDK 1.7.
    javac.exe version 7.0.20.13

  6. #6
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,562
    Rep Power
    25

    Default Re: Weird error(connecting to a ServerSocket)

    Thanks. New syntax I see.

Similar Threads

  1. BlueJ help! weird error text meesed up
    By linux1man in forum Other IDEs
    Replies: 6
    Last Post: 02-07-2013, 03:54 PM
  2. Weird Error With Methods
    By skaterboy987 in forum New To Java
    Replies: 15
    Last Post: 10-17-2011, 03:45 AM
  3. error while connecting
    By jyothi_tallapaneni in forum Networking
    Replies: 0
    Last Post: 04-15-2010, 08:01 AM
  4. [SOLVED] Simple Calculator Applet Weird Error
    By sari in forum New To Java
    Replies: 5
    Last Post: 01-28-2009, 04:57 AM
  5. Weird Error?
    By sciguy77 in forum New To Java
    Replies: 4
    Last Post: 01-20-2009, 02:32 AM

Posting Permissions

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