[Newbie] Need Help with Java!

Discussion in 'Mac Programming' started by pintsizemacman, May 26, 2012.

  1. pintsizemacman, May 26, 2012
    Last edited: May 26, 2012

    pintsizemacman macrumors regular


    Sep 26, 2010
    So I'm not really the one organizing and coding this add-on.

    The one coding the Mac version of the add-on is doing it in Java.
    I'm trying to test out this, close to final, version of the add-on, but I get an error that is yet to be resolved. I need fast help or any help would be appreciated!

    Mac OS X 10.7.3 Java SE 6


    Error : java.io.FileNotFoundException: null/addon/debug/debug.log (No such file or directory) 
    I Hit OK* and Window reappears x3

    Then: The java JAR file "Addon_Client.jar" could not be launched window.

    Please help me :confused:
  2. kryten2 macrumors 6502a

    Mar 17, 2012
  3. chown33 macrumors 604

    Aug 9, 2009
    Show the error to the person doing the coding. To me, it doesn't look like something you can correct without further instructions from them. Frankly, it looks like a bug in the code.

    And I don't think kryten2's suggestion will fix it, because the problem is that "null" is being used as a directory name.

    Error : java.io.FileNotFoundException: [COLOR="Red"]null[/COLOR]/.jffaddon/debug/debug.log (No such file or directory) 

    If I had to guess, I'd say the code is doing something vaguely similar to this:
    String someDir = somethingThatReturnsADirname();
    String hopefulPath = "" + someDir + "/.jffaddon/debug/debug.log";
    SomeKindOfOutputStream out = new FileOutputStream( hopefulPath );
    The bug lies in how hopefulPath is assembled. By starting with "" and then appending, if someDir is null you'll get the actual string "null" in the result, and there won't be any NullPointerException. If it was done like this:
    String hopefulPath = someDir + "/.jffaddon/debug/debug.log";
    then there would be a NullPointerException instead of a string with literal "null" in it.

    However it does it, the code eventually ends up with this string:
    which it then tries to open for output (possibly for input, but that'd be abnormal for a log file). Because there's no directory actually named "null", the attempt to open the file fails.

    Perhaps somethingThatReturnsADirname() is trying to read a system property, and you've failed to define that property. Or you think you've defined it but somehow made a mistake.

    Without seeing the actual code, and knowing what it does and what it expects, I don't see how anyone here can give a definitive answer or solution. You need to talk to the code's author, show them the error message, and explain exactly what you did.
  4. pintsizemacman thread starter macrumors regular


    Sep 26, 2010
    Ok Thanks for your fast reply's and help! I will keep you updated :)

    @kryten: It didn't work :(

Share This Page