Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between building and deploying a Java Web project?

I know that

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.

(thanks to Ignacio Vazquez-Abrams).

But when I want to see my changes in a Java Web project I also have to deploy them (after building). What does Netbeans do when I deploy my project?

like image 957
Martin Thoma Avatar asked Feb 23 '23 08:02

Martin Thoma


1 Answers

Your definitions seem to come from the world of native code compilers (C, C++, Pascal, etc). In Java, compilation is just the process of turning Java code (text) into Java bytecode which is also a high-level code, rather than object (machine) code.

Linking in Java happens each time the application runs inside the virtual machine, where symbols in the bytecode are resolved to references to other loaded bytecode. So the sequence in java is actually: Compile -> Deploy -> Link -> Run.

Once running, the JVM may choose to turn the Java bytecode into machine code for direct execution but it can also just interpret the bytecode.

In this case deploying just refers to telling the application server where the code is and running the startup code as defined in the application descriptor (e.g. Servlet and Filter initialization defined in web.xml for webapps).

like image 66
Ramon Avatar answered Apr 07 '23 13:04

Ramon