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

  • Home
  • SEARCH
  • 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 8819383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:20:41+00:00 2026-06-14T05:20:41+00:00

I am trying to build a java microblogging app I have finished the code

  • 0

I am trying to build a java microblogging app
I have finished the code but cannot connect to my own computer due to the following error (I google it and someone said I need to change the port number. I changed the port number and nothing happened)

Exception in thread "Thread-4" java.net.BindException: Address already in use: JVM_Bind

Below is the code for the server:

public class server extends Thread {
    public Socket client = null;
    public ServerSocket server = null;
    private int port = 4444; 

public void run(){  
    while (true){ //loop waits for incomming connection
        try { //start the server and listen to a port
                server = new ServerSocket(port);
            }catch (IOException e){
                System.err.println(e);
                System.exit(-1);
            }

            try { //establish a connection when receiving request
                client = server.accept();
            }catch (IOException e){
                System.err.println(e);
                System.exit(1);
            }

            Thread t = new Thread(new Connection(client));
            t.start();
        }
    }
}

And this is the code to start the server and listen to port 4444

Server server = new Server();
server.start(); //to listen to a port

Thank you

  • 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-14T05:20:43+00:00Added an answer on June 14, 2026 at 5:20 am

    You must create the ServerSocket before entering the loop. At present you are trying to create it every iteration, which doesn’t make sense, and you aren’t closing it, so the second creation fails.

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

Sidebar

Related Questions

I have been trying to build an online java compiler. But running the clients
I'm trying to build my Flex/Java web app from within IntelliJ rather than have
I am trying to build a Java SNMP client. I have a folder on
I'm trying to build a java application with gcj but getting the error below.
I am trying to run a Java webapp build instance but it stops in
I am trying to build RPM for my java code.RPM build and install sections
I am trying to build an MVC application in Java Swing. I have a
I've been trying to build this small java app. I find it very difficult
I am trying to build a controller using Luaj + java. I have the
I am currently trying to build a Java Project with several dependencies. I have

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.