title: Exception in thread "main" java.net.BindException: Address already in use - Error in Netbeans only
body: <p>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".</p>
  
  <p>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.</p>
  
  <p>Server.java</p>
  
  <pre><code>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);
  
      }
  
  }
  </code></pre>
  
  <p>Client.java</p>
  
  <pre><code>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");
  
      }
  
  }
  </code></pre>