user3760992
user3760992

Reputation: 29

C and java compilation process in Windows

What I know in Windows:

please rectify :

I'm really confused each time I seek for these processes could any one give me the details in C and java from source code to CPU in windows and giving names of programs such as compilers and assemblers

Upvotes: 0

Views: 139

Answers (2)

Stefan Falk
Stefan Falk

Reputation: 25387

As can be taken from Java Virtual Machine

The Java virtual machine is called "virtual" because it is an abstract computer defined by a specification.

This tells us that there must be somehow a quite big difference between bytecode generated by a C compiler and/or the Java compiler.

If you are using e.g. gcc, as you already mentioned, the code is translated to assembly and then translated to binary by an assembler (let's skip the Linker). These binary instructions are being loaded as you execute your .exe file. Windows reserves some physical pages for your process, sets up the virtual memory and starts to execute your program in userspace but without any detours.

The JVM on the other hand is a virtual computer in the sense that it "pretends" to be a machine on its own. This machine only understands the Java-Bytecode (yes, there is such a thing ah "Java-Assembly" too). But there is more. Because in order to actually work, the JVM has to execute that bytecode somehow on that "host machine. So the JVM has to interfere with the underlaying operating system and architecture. And this is what the JVM really does: It is a program that is written for some architectures and runs on some operating systems that pretends to be a "machine" in order to execute Java-Bytecode. This is what it makes "platform independent".

Long story short:

Basically, there is happenning the "same" thing. Code gets translated to assembly, to binary and then gets executed on a "machine".

Upvotes: 1

Stephen C
Stephen C

Reputation: 718788

please rectify:

The java.exe does not generate assembly code. Instead, it executes the program. There is nothing in the standard Java toolchain that generates assembly code ... or a separate executable program.

(Under the covers, the java.exe program may decide to JIT compile the bytecodes in the classfile to native code instructions. But that happens on the file (JIT means just in time) and the resulting native code is not saved to a file. And it is certainly not "assembly code" either.)


As for the names of the various executables for C compilation on Windows, it depends on which compiler toolchain you decide to use. I'll leave that for someone else to answer.

Upvotes: 0

Related Questions