Exception in thread "main" java.lang.NullPointerException at com.perihelionds.text2peer.Text2Peer.acceptMsg(Text2Peer.java:42) at com.perihelionds.text2peer.Text2Peer.setListener(Text2Peer.java:34) at com.perihelionds.text2peer.Text2Peer.main(Text2Peer.java:26)
I've spent many hours trying to get it work and am at a loss for ideas. Below are the relevant methods.
public static void main(String[] args) throws Exception {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
g = new GUI();
g.setVisible(true);
}
});
setListener();
}
public static void setListener() throws IOException
{
ServerSocket welcomeSocket = new ServerSocket(5678);
while(true){
Socket handlerSocket = welcomeSocket.accept();
acceptMsg(handlerSocket);
}
}
public static void acceptMsg(Socket s) throws IOException {
InputStream inFromClient = s.getInputStream();
InputStreamReader inReader = new InputStreamReader(inFromClient);
BufferedReader reader = new BufferedReader(inReader);
String line = reader.readLine();
newLine.setText(line); //Here is where the error points to
g.setMainChat(newLine);
}

New Topic/Question
Reply



MultiQuote




|