Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8002683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:26:10+00:00 2026-06-04T16:26:10+00:00

Hello I am having some problems with the code below. The try and catch

  • 0

Hello I am having some problems with the code below. The try and catch blocks have a red X at the try line in my IDE telling me that a “(” was encountered but a “{” was expected. Am I missing something? What could be my problem?

import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.StandardSocketOptions;
import java.nio.ByteBuffer;
import java.nio.channels.AsynchronousServerSocketChannel;
import java.nio.channels.AsynchronousSocketChannel;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
/** * * @author Apress */

public class FutureForm 
{
public static void main(String[] args) 
{
    final int DEFAULT_PORT = 5555;
    final String IP = "127.0.0.1";
    // v-This parenthesis should be a bracket it says??
    try( AsynchronousServerSocketChannel asynchronousServerSocketChannel = AsynchronousServerSocketChannel.open()) 
    {
        if (asynchronousServerSocketChannel.isOpen()) 
        {
            asynchronousServerSocketChannel.bind(new InetSocketAddress(IP, DEFAULT_PORT));
            System.out.println("Waiting for connections ...");
            while (true) 
            {
                Future<AsynchronousSocketChannel> asynchronousSocketChannelFuture = asynchronousServerSocketChannel.accept();
                try (AsynchronousSocketChannel asynchronousSocketChannel = asynchronousSocketChannelFuture.get()) 
                {
                    System.out.println("Incoming connection from: " + asynchronousSocketChannel.getRemoteAddress());
                    final ByteBuffer buffer = ByteBuffer.allocateDirect(1024);
                    while (asynchronousSocketChannel.read(buffer).get() != -1) 
                    {
                        buffer.flip();
                        asynchronousSocketChannel.write(buffer).get();
                        if (buffer.hasRemaining()) 
                            buffer.compact();
                        else 
                            buffer.clear();
                    }
                    System.out.println(asynchronousSocketChannel.getRemoteAddress() + " was successfully served!");
                } 
                catch (IOException || InterruptedException || ExecutionException ex) 
                {
                    System.err.println(ex);
                }
            }
        } 
        else 
        {
            System.out.println("The asynchronous server-socket channel cannot be opened!");
        }
    } 
    catch (IOException ex) 
    {
        System.err.println(ex);
    }
}
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T16:26:11+00:00Added an answer on June 4, 2026 at 4:26 pm

    Verify that you have configured your workspace for Java 1.7, in Preferences under Java>Compiler: “Compiler compliance level.”

    If that doesn’t help, check the project properties under Java Compiler, which should either not have project-specific settings, or have 1.7 configured.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello i am having some problems generating random numbers with C# Now i have
I'm having some problems with Code::Blocks, and this is the output after / while
I have some code that is working correctly in Java but when I try
Hello i am having some problems sending mails thoug my site. I keep getting
I've tried to simplify a problem I'm having with the code below. Some of
I'm having a really nasty problem with some code that I've written. I found
Hello guys I am having some problems with exact matches while doing a NamedQuery.
hello i like to code a filter for my search engine. i have some
Hello i'm having some trouble in displaying multiple pushpins on maps. So far i've
hello friends i am working on a like module .and having some difficulties running

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.