编辑:我忘记在 Eclipse 中将启动类更改为客户端包!
这很奇怪,它在 Eclipse 中运行良好,然后我导出它,它给了我一个java.lang.NumberFormatException
.
Start.java的pastebin
转储:
Exception in thread "main" java.lang.NumberFormatException: For input string: "gudenau.no-ip.org"
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.<init>(Unknown Source)
at com.gudenau.ChatServer.Start.main(Start.java:141)
我不明白为什么它在 Eclipse 中有效,但不适用于批处理文件。
我用于套接字的代码是
socket = new Socket("gudenau.no-ip.org", 45678);
稍后我会将其更改为不是静态的。
try {
socket = new Socket("gudenau.no-ip.org", 45678);
out = new PrintWriter(socket.getOutputStream(), true);
in = new BufferedReader(new InputStreamReader(
socket.getInputStream()));
} catch (NumberFormatException e) {
e.printStackTrace();
System.exit(-1);
} catch (UnknownHostException e) {
e.printStackTrace();
System.exit(-2);
} catch (IOException e) {
e.printStackTrace();
System.exit(-3);
}
编辑 141 左右的代码:
@Override
public void windowIconified(WindowEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void windowOpened(WindowEvent arg0) {
// TODO Auto-generated method stub
}