Take the 2-minute tour ×

Thinking that the answer to this is pretty obvious but here it goes:

When I am working on a small project for school (in java) I "compile" it.

On my coop we are using ant to "build" our project.

I think that compiling is a subset of building. Is this correct? What is the difference between building and compiling?

What is the difference between compiling and building?

share|improve this question
If building is a war, then compiling is a battle. –  Dave Jarvis Apr 17 '10 at 1:26
add comment

6 Answers

up vote 30 down vote accepted

The "Build" is a process that covers all the steps required to create a "deliverable" of your software. In the Java world, this typically includes:

  1. Generating sources (sometimes).
  2. Compiling sources.
  3. Compiling test sources.
  4. Executing tests (unit tests, integration tests, etc).
  5. Packaging (into jar, war, ejb-jar, ear).
  6. Running health checks (static analyzers like Checkstyle, Findbugs, PMD, test coverage, etc).
  7. Generating reports.

So as you can see, compiling is only a (small) part of the build (and the best practice is to fully automate all the steps with tools like Maven or Ant and to run the build continuously which is known as Continuous Integration).

share|improve this answer
add comment

Some of the answers I see here are out-of-context and make more sense if this were a C/C++ question.

Short version:

  • "Compiling" is turning .java files into .class files
  • 'Building" is a generic term that includes compiling and other tasks.

"Building" is a generic term describes the overall process which includes compiling. For example, the build process might include tools which generate Java code or documentation files.

Often there will be additional phases, like "package" which takes all your .class files and puts them into a .jar, or "clean" which cleans out .class files and temporary directories.

share|improve this answer
add comment

Compiling is the act of turning source code into object code.

Linking is the act of combining object code with libraries into a raw executable.

Building is the sequence composed of compiling and linking, with possibly other tasks such as installer creation.

Many compilers handle the linking step automatically after compiling source code.


share|improve this answer
Some other possible tasks: enhancing (JDO), Javadoc-ing, packaging, and signing. In addition, some environments including running automated unit/regression tests as part of a "build". –  Bert F Apr 16 '10 at 3:32
Normally, there is no linking step when building Java projects, and no raw executable is produced. Rather, the compiled classes are packaged together into a .jar file as part of the build. (Or .war, or .ear, depending on your target environment.) –  markusk Apr 16 '10 at 5:12
Dude, this is pure copy&paste and not even appropriate for Java... –  Pascal Thivent Apr 16 '10 at 5:30
what are "raw executable"? –  ealeon Jul 23 '13 at 18:15
The bag of bits that is basically useless on it's own without being mixed in with the other libraries it needs. It's much like a chocolate cake. Without the flour and eggs, etc, the cocoa is just raw cocoa. –  Kaili Jul 31 '13 at 19:45
add comment

In simple words

Compilation traslates java code (human readable) into bytecode, so the Virtual machine understands it.

Building puts all the compiled parts togheter and creates (builds) an executable.

share|improve this answer
add comment

Actually you are doing the same thing. Ant is build system based on XML configuration files that can do a wide range of tasks related to compiling software. Compiling your java code is just one of those tasks. There are many others such as copying files around, configuring servers, assembling zips and jars, and compiling other languages such as C.

You don't need Ant to compile your software. You can do it manually as you are doing at school. Another alternative to Ant is a product called Maven. Both Ant and Maven do the same thing , but in quite different ways.

Lookup Ant and Maven for more details.

share|improve this answer
You can also see what ant is actually doing by looking the buildfile (most likely called build.xml). Even if you're not familiar with the syntax, you can kind of see what's going on. <javac> means it's compiling some Java code. <java> means it's actually running the compiled code. Probably it's creating a directory to put the .class files in, compiling the code, maybe creating some Javadoc, etc. –  MatrixFrog Apr 16 '10 at 4:57
add comment

Compiling is just converting the source code to binary, building is compiling and linking any other files needed into the build directory

share|improve this answer
add comment

Your Answer


