1

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

http://pastebin.com/KxfApWKb

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

}
9
  • can you show us the source code in question? Commented Jun 7, 2012 at 17:01
  • Shure: 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); } Commented Jun 7, 2012 at 17:03
  • Your code is OK. Are you sure you don't have a firewall on which you might have authorized Eclipse ? Commented Jun 7, 2012 at 17:11
  • I am pretty sure, it is a java problem is it not. Commented Jun 7, 2012 at 17:12
  • Are you calling Integer.parseInt() or any other method near line 141 in your code ? It would be better if you place SSCCE Commented Jun 7, 2012 at 17:19

3 Answers 3

1

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.

Sign up to request clarification or add additional context in comments.

4 Comments

Update after reading your pastebin. The class you added in there has a package of "com.gudenau.ChatCleint", you need to look at the class with the package of "com.gudenau.ChatServer".
But the problem is in the cleint... How does that help?
@gudenau - the exception is thrown from com.gudenau.ChatServer.Start.main() at line 141
Oh, I think I know how to fix this!
0

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

Comments

0

I needed to change the start class in the eclipse jar exporter! Oops!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.