Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Building vs. Compiling (Java)

People also ask

What is the difference between building and compiling?

These terms are often used interchangeably, but I would differentiate them in the following way: Building is done when preparing an application for release, which includes compiling, packaging, testing, etc. Compiling is done at any time the compiler is involved in translating programming language code to machine code.

What is the difference between build and compile in terms of program execution?

The difference between build and compile is that build is the process of compiling and linking a program, while compile is the process of translating a program written in a high-level programming language to machine code. In simple words we can say that Build is a compiled version of a program.

What is building a Java project?

A Java project contains source code and related files for building a Java program. It has an associated Java builder that can incrementally compile Java source files as they are changed. A Java project also maintains a model of its contents.

What is the difference between compiling and running Java program?

Compile time is the period when the programming code (such as C#, Java, C, Python) is converted to the machine code (i.e. binary code). Runtime is the period of time when a program is running and generally occurs after compile time.


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).


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.


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.

What is the difference between compile code and executable code?


In simple words

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

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


  • Build is a compiled version of a program.
  • Compile means, convert (a program) into a machine-code or lower-level form in which the program can be executed.

In Java: Build is a Life cycle contains sequence of named phases.

for example: maven it has three build life cycles, the following one is default build life cycle.

◾validate - validate the project is correct and all necessary information is available
◾compile - compile the source code of the project
◾test - test the compiled source code using a suitable unit testing framework. These tests should not require the code be packaged or deployed
◾package - take the compiled code and package it in its distributable format, such as a JAR.
◾integration-test - process and deploy the package if necessary into an environment where integration tests can be run
◾verify - run any checks to verify the package is valid and meets quality criteria
◾install - install the package into the local repository, for use as a dependency in other projects locally
◾deploy - done in an integration or release environment, copies the final package to the remote repository for sharing with other developers and projects.

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.


In Eclipse and IntelliJ, the build process consist of the following steps: cleaning the previous packages, validate, compile, test, package,
integration, verify, install, deploy.