Normally languages like C and C++ compile their code directly into machine code to be executed by the machine.
This machine code is specific to the machine and operating system you are executing in and sometimes it may not work.
Now here's why JavaC is better than GCC or any C compiler.
Java has an intermediate step during compiling it.
It converts Java file into another human readable .java file into ByteCode which is a format that is neutral and readable across many operating systems unlike GCC.
JVM
This is Java's virtual machine.. In my last post we saw how an command is taken from shell all the way to the kernel to the Hardware using a system call now instead of this we execute the code using this virtual machine called JVM now this sits on top the operating system
But how? There is a specific jvm version for all operating systems for almost all operating systems Now the jvm converts this byte code into machine code that the specifc machine understands or system calls that the machine can use
Evolving
The concept of build once run anywhere has now evolved tools like docker and other containerization platforms have adopted this principle and have used it to build working applications that run anywhere
In the next post we are going to dig deeper into virtual machine and the most popular virtual machine WSL

Top comments (0)