Article:
  Building a Simple Java Application in Mac OS X
Subject:   Author's response
Date:   2003-02-10 07:45:37
From:   dsteinberg
Response to: Try banging your head against the wall for a bit

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

Full Threads Oldest First

Showing messages 1 through 2 of 2.

  • 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"