Women in Technology

Hear us Roar

  Building a Simple Java Application in Mac OS X
Subject:   Try banging your head against the wall for a bit
Date:   2003-02-07 17:46:04
From:   anonymous2
I couldn't get it to run either the first dozen times. For some inexplicable reason after a few rounds of getting rid of the old .class files and retyping parts of the code that weren't being executed and rebuilding, it started to work. I then had a similar problem with responding to the MouseEvent. Several (clean, retype and recompile)s later it started to work. I didn't find any bugs or typos it just started working. Managed to get all the way though it but I am slightly balder now because of it.

I really hope this is stab it the dark method is not typical of Java development. What kind of tools are there for debugging? There would obviously be something that comes with an IDE so using a generic text editor can be a problem, but there must be some cli tools.

Full Threads Oldest First

Showing messages 1 through 3 of 3.

  • Daniel H. Steinberg photo Author's response
    2003-02-10 07:45:37  Daniel H. Steinberg | O'Reilly AuthorO'Reilly Blogger [View]

    It is most likely a problem of packaging. It matters where you put your .java files and from where you do the compiling and running. This example has been used (since it appeared here) in intro classes without problems exactly as it's written. Here are the keys that you may have missed. First, all of the files begin with the package statement "package NineSquares". This means that all of the .java files are inside of a directory with the name "NineSquares". The case must match exactly. Second, your compiling and running of the files must happen from outside of the NineSquares directory. For example the file EachSquare.java is inside of NineSquares. If you try to compile it from inside of NineSquares using "javac NineSquares/EachSquare.java" then the compiler looks for a directory named NineSquares inside of the directory named NineSquares. Inside of this second NineSquares directory it is looking for EachSquare.java.

    I don't understand your last comments. My article used cli tools for the running of the java. I stayed away from ProjectBuilder because it is not very good at dealing with packages and tends to be hard for beginning Java programmers for this reason. As for debugging, since adopting test first programming a year and a half ago, I have not found myself in a debugger since.

    Best, Daniel

    • figured out NoClassDef error problem
      2003-04-05 13:10:28  anonymous2 [View]

      • again: figured out NoClassDef error problem
        2003-04-05 13:12:51  anonymous2 [View]

        The text of the article has

        "java NineSquares/NineSquares."

        the "." causes the problem. The run line should be

        "java NineSquares/NineSquares"