public void run() {
    java.net.Socket socket;

    // accept a connection
    try {
      socket = server.accept();
    } catch (java.io.IOException e) {
      System.out.println("Class Server died: " + e.getMessage());
      e.printStackTrace();
      return;
    }

    // create a new thread to accept the next connection
    newListener();
    try {
      java.io.DataOutputStream out = new java.io.DataOutputStream(socket.getOutputStream());
      String path = null;
      try {
        // get path to class file from header
        java.io.BufferedReader in = new java.io.BufferedReader(new java.io.InputStreamReader(socket.getInputStream()));
        path = getPath(in);
        // retrieve bytecodes
        byte[] bytecodes = getBytes(path);
        // send bytecodes in response (assumes HTTP/1.0 or later)
        try {
          out.writeBytes("HTTP/1.0 200 OK\r\n");
          out.writeBytes("Content-Length: " + bytecodes.length + "\r\n");
          out.writeBytes("Content-Type: application/java\r\n\r\n");
          out.write(bytecodes);
          out.flush();
          System.out.println("ClassServer loaded class " + path + " successfully.");
        } catch (java.io.IOException ie) {
          return;
        }
      } catch (Exception e) {
        // write out error response
        System.out.println("!!! ClassServer failed to load class " + path + ".");
        out.writeBytes("HTTP/1.0 400 " + e.getMessage() + "\r\n");
        out.writeBytes("Content-Type: text/html\r\n\r\n");
        out.flush();
      }
    } catch (java.io.IOException ex) {
      // eat exception (could log error to log file, but write out to stdout for now).
      //System.out.println("error writing response: " + ex.getMessage());
      //ex.printStackTrace();
    } finally {
      try {
        socket.close();
      } catch (java.io.IOException e) {
      }
    }
  }