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 9248767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:01:19+00:00 2026-06-18T10:01:19+00:00

On my machine, the following code compiles within Eclipse but throws an exception within

  • 0

On my machine, the following code compiles within Eclipse but throws an exception within Netbeans. The error message says “Exception in thread “main” java.net.BindException: Address already in use”.

What is the proper configuration within Netbeans to make this code compile? It seems like the problem has to do with the fact that I have two main functions. If I start running either one of the apps, the second will fail to start, throwing the exception posted above.

Server.java

import java.io.*;
import java.net.*;

public class Server {

    public static void main(String[] args) throws Exception {

        Server myServ = new Server();
        myServ.run();

    }

    public void run() throws Exception {

        ServerSocket mySS = new ServerSocket(9999);
        Socket SS_accept = mySS.accept();

        InputStreamReader mySR = new InputStreamReader(SS_accept.getInputStream());
        BufferedReader myBR = new BufferedReader(mySR);

        String temp = myBR.readLine();
        System.out.println(temp);

    }

}

Client.java

import java.io.*;
import java.net.*;

public class Client {

    public static void main(String[] args) throws Exception {

        Client myCli = new Client();
        myCli.run();

    }

    public void run() throws Exception {

        Socket mySkt = new Socket("localhost", 9999);
        PrintStream myPS = new PrintStream(mySkt.getOutputStream());

        myPS.println("Hello server");

    }

}
  • 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-18T10:01:21+00:00Added an answer on June 18, 2026 at 10:01 am

    The way to achieve what I want is to right-click on the particular class (ex. Server.java) that I want to run and select “Run this file”. This enables me to run only the Server app. Then, do the same process for the other file, Client.java.

    However, Netbeans is somewhat confusing/deceiving in this particular circumstance. What Netbeans does is it runs the Server process, but labels that process as the name of the project (ex. MyTestNetworkingProject) and puts a run number on it, thus giving us MyTestNetworkingProject run #1 (it actually leaves out the #1 on the first process). Then, if I go to the Client.java file and select “Run this file”, it generates a second process, MyTestNetworkingProject run #2. It then generates a second results window down at the bottom of the screen, as it generates these in new tabs as new processes get created.

    Because of the nature of my specific code, what I wanted to see in my results window to confirm that my application was working was I wanted to observe the Server.java results window (which in this case is MyTestNetworkingProject run #1). Given my exact sequence of steps outlined above of running the different files, run #2 is the last run process and thus the tab on top, covering the run #1 tab. I can click on run #1 and see the results I was hoping to see in the console (“Hello server”), but I just have to know/remember that MyTestNetworkingProject run #1 represents the Server app and not the Client app.

    Uncool, IMO.

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

Sidebar

Related Questions

The following code compiles fine, but does not allow the user to choose whether
The following code for a co-worker throws the following error when he tries to
Please have a look at the following machine code ‎0111001101110100011100100110010101110011011100110110010101100100 This means something. I
My machine apparently won't draw vertex lists in pyglet. The following code renders two
On a Solaris 5.8 machine, I have the following code: [non-working code] char *buf;
i executed the following c code on my ubuntu machine...i have read about fcntl()'s
I downloaded the qt embedded demo source code recently on my linux machine. Following
The following C++ program crashes on my Windows XP machine with a message Abnormal
I meet following exception when I copy the whole program directoy to another machine.
Having done a brief search on the following error code from GCC, a number

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.