Friday, October 12, 2007

Java Faqs - Can I compile group of java files once?

The first way isjavac *.java

Another way isjavac -depend tip.java

where "tip.java" is a class "at the tip of the iceberg", i.e. that depends on (uses) all the other classes. Typically, this may be your main class. However, "-depend" is known to be buggy and cannot be relied upon. It also doesn't issue compile commands in parallel to make use of multi-processor systems.Without the "-depend" option, the standard "javac files" doesn't look beyond the immediately adjacent dependencies to find classes lower down the hierarchy where the source has changed.The -depend options searches recursively for depending classes and recompiles it. This option doesn't help when you have dynamically loaded classes whose names cannot be determined by the compiler from the dependency graph. E.g. you use something likeClass.forName(argv[0]);The author of the code using those classes should make sure that those classes are mentioned in a Makefile.

By Shantan Nethikar

No comments: