conrad wrote:
>> Could someone point me in the right direction
>> in how one should compile a program in
>> java with multiple source files? In C, or
>> C++ I would have separate translation units
>> that serve some particular purpose.
>> I would then compile those translation
>> units into object files and then supply
>> all the object files to the compiler
>> to generate a single output file.
>> One of my translation units would have
>> main in it. Now, I'm wondering how this
>> is approached in java because I really don't
>> want a single class with many unrelated
>> methods.
Arne Vajhøj wrote:
> Each .java file becomes a .class file.
>
> You can "bundle" many .class files in a .jar file.
>
> I think that is what you want to use.
In addition to the others' advice, which cover the primary points, both the
"loose" class files and the internal structure of a JAR file follow Java's
package structures, and strictures.
Packages define and limit accessibility of classes to each other.
Semantically, they are namespaces to the language, and object-file (to use C
parlance) organizers to the deployer. The directory/moredirectory/file
hierarchy in the file system or JAR corresponds to the
package.morepackage.class dotted notation of the (non-hierarchical) namespace
system.
To carry the C-to-Java analogy forward, a .class is like a .o (.obj), a
package is like a .a (.lib), and a JAR is like a .out (.exe).
--
Lew