• Post Reply Bookmark Topic Watch Topic
  • New Topic

Compiling classes  RSS feed

 
Jim Thompson
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you compile a Java class, does it compile all classes that have a reference in that class, all references in those classes, and so forth; both instances and static methods from other classes? Are library classes compiled when called from a class?
Thanks

 
Joel McNary
Bartender
Posts: 1840
Eclipse IDE Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It compiles all classes that need to be compiled; that is, if there is no .class file or if the .java file (if found) is more recent than the .class file. As such, the library classes are not compiled, as they are already compiled.
 
Jim Thompson
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So what is the point of make files like Ant?
 
Jim Thompson
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So what is the point of make files like Ant?
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Say that class A uses class B, and B uses C.
If no class files exist, then compiling A would create all 3.
Now, let's say you drastically change C, so that both A and B really need to be compiled. Then compile A. The compiler looks at B, sees that its B.class file is up to date with respect to its B.java file, and does nothing. C gets compiled, as does A, but B isn't touched. You may now get a runtime error.
A good build tool can (among other things) keep track of this kind of dependency; you can tell it that B depends on C, so that modifying C will force B to be recompiled.
Of course, build tools do a lot of other things too: automate version control, packaging, installation, testing, and other parts of development.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!