Reputation: 530
Edit: I was forgot to change the start class to the client package in Eclipse!
This is odd, it works fine in eclipse, then I export it and it gives me a java.lang.NumberFormatException
.
The pastebin of Start.java
The dump:
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)
I don't get why it works in eclipse but not with a batch file.
The code I use for the socket is
socket = new Socket("gudenau.no-ip.org", 45678);
I will change this to not be static later.
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);
}
Edit the code around 141:
@Override
public void windowIconified(WindowEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void windowOpened(WindowEvent arg0) {
// TODO Auto-generated method stub
}
Upvotes: 1
Views: 1854
Reputation: 530
I needed to change the start class in the eclipse jar exporter! Oops!
Upvotes: 0
Reputation: 388
The code you added for line 141 doesn't seem to be correct (I could be wrong). The error is coming from a class called Start (line 141). I am guessing you are trying to create an Integer there, but from a String that does not parse into an Integer.
You may want to add a debug point at that method (or some System.outs) to see what you are actually trying to convert to an Integer.
Update: you are looking at the wrong package, you need com.gudenau.ChatServer, not com.gudenau.ChatCleint.
Upvotes: 1
Reputation: 28762
The stack trace you show indicates that the exception is from line 141 of Start.main()
, which directly instantiates an Integer
object. Since the Socket
constructor is taking a primitive int
, this cannot be the actual problem. Please update your post with the code surrounding line 141 of Start.main()
for a better answer
Upvotes: 0