I'm betting you're running the compiler with "xtract" as your current directory, like
Don't do that. Your current directory should be "src" and you should use
Yes, that's a lot of typing: in real life, you'd use something like Ant to build your software.
Anyway, based on the package name, the compiler is looking for con/kilo/xtract/A.class, and not finding it. That's why you want to have "src" as your current directory. There are other ways to deal with this, but this is the most straightforward one.
Yes, you were correct. I was trying to compile from "xtract".
I have a parallel set of directories for the .class files:
dev ..|---src ..|.....|---com ..|...........|---kilo ..|..................|---xtract ..|---bin ........|---com ..............|---kilo .....................|---xtract
I tried compiling with "src" as the current directory. I used the -cp command-line switch ("-cp %CLASSPATH%;../bin/com/kilo/xtract"), but I still got an error from the compiler telling me that it couldn't find the symbol.
author and iconoclast
That is, it takes the directory from the classpath, adds a folder for every package fragment for the class, and then searches the class in that path.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Joined: Mar 19, 2006
Thanks! That clears things up. To recapitulate:
1) Compile from the directory that contains the sub-directory corresponding to the first element of the package name. For example, if the directory structure is like this:
/dev/java/src/com/kilo/xtract and /dev/java/bin/com/kilo/xtract
and the package statement reads "package com.kilo.xtract;"
you should compile from /dev/java/src.
2) If the .class files are in the directories under /dev/java/bin and you are compiling from /dev/java/src, then the classpath should contain the string "../bin". That is to say, "go up one directory level and then down the directory tree to "bin".
3) The compiler will read the package statement from the .java file and starting at /dev/java/bin, it will navigate down through the directory tree to find the necessary .class file(s) by appending to "../bin" each directory name listed in the package statement in order from left to right so that the effective classpath in this example will be "../bin/com/kilo/xtract". [ April 26, 2006: Message edited by: Charles Knell ]
author and iconoclast