Results 1 to 6 of 6

Thread: Ridiculous Java problem

  1. #1
    Member Spardan's Avatar
    Join Date
    Feb 2003
    Location
    Drunk and Disordered
    Posts
    221

    Ridiculous Java problem

    This is driving me nuts...

    I am using a standard:

    int x = Integer.parseInt(someString);

    to parse a string read in from the console to an int.

    This works fine when running/compiling in JBuilder (X), but when I run from either the jar, the class, or an executable, I get exceptions caused by the parseInt() method.

    I'm guessing that this is an environmental thing rather than anything else, but I don't see how... I've checked >set java

    ... the exact same setup was running RMI, and the jre was happily working with jBoss to serve EJB2.0s...

    Anybody got any clues at all?

    Running Windows 2k and XP (test envs) with Java 1.4.05

    Thanks!
    ++Spardan++

  2. #2
    Ultimate Member DocEvi1's Avatar
    Join Date
    Dec 2001
    Posts
    2,330
    int x = new Integer("someString").intValue();
    Stefan

  3. #3
    Member Spardan's Avatar
    Join Date
    Feb 2003
    Location
    Drunk and Disordered
    Posts
    221
    Thanks Doc - tried that out and was failing too. Problem is that JBX is running in the console with *NIX input (\n) from the return key, and obviously Windows runs with CR-LF (\r\n)...

    Was under the impression that I'd told JBX how to behave, but apparently not... and can find no **** way to change this. Ah well... Eclipse looks better and better all the time...

    wow... these forums '*' even "damn"? (Sorry, ascii'd it)...

    better write an app called "damnware", then... :P
    Last edited by Spardan; 04-14-2005 at 09:25 AM.
    ++Spardan++

  4. #4
    Ultimate Member DocEvi1's Avatar
    Join Date
    Dec 2001
    Posts
    2,330
    too many kids with nothing better to do The mods have to protect their pureile little minds somehow

    What string are you passing to the parseInt method? It might be worth making sure that you are only passing a String which can be parsed (I think you have it with the \r\n jobie).
    Stefan

  5. #5
    Member Spardan's Avatar
    Join Date
    Feb 2003
    Location
    Drunk and Disordered
    Posts
    221
    yeah, it's a \r\n thing. Strange that I can't configure Jbuilder to imitate an environment. Means I have two lines in my parser, one commented out when running in JB, and then compiled live to run in the console... handy
    ++Spardan++

  6. #6
    Member GrefMofovich's Avatar
    Join Date
    Oct 2003
    Location
    Right BEHIND YOU!
    Posts
    256
    tsk tsk. didn't your compiler tell you, there are no ridiculous problems, only ridiculous programmers!

    in light of that, why not use a laser. evidently they can solve every problem facing humanity today: vision correction, tooth whitening, hair removal, sensing mouse moves, sensing arabs for nuking, invading weaker planets, burning naughty movies to hideable DVDs, etc etc.

    -GM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •