conrad
a3fc00264bcc@n75g2000hsh.googlegroups.com:
> 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.
>
> --
> conrad
>
In C or C++ you first compile to object files, and then link them together
to get an executable.
In Java you just compile the source files to class files, and they are
immediately executable. There is no need for "linking" them together.
You start the application with the class having the main() and java just
finds the other class files when it needs them.
That way, your application contains lots (tens, hundreds, thousands) of
.class files on the disk. Painful.
You can pack the application into a .jar file - which is actually a .zip
having the classes in it. There may also be a special MANIFEST file in it,
which may contain the main class name in it, so the .jar can be handled as
a real executable which starts with a double click.
You might want to spend some time with the Java tutorials on
http://java.sun.com/docs/books/tutorial/