Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C and Java / Virtual machine code execution [duplicate]

Tags:

java

c

I am fairly new to Java and I was wondering why Java uses a virtual machine (the java program) to execute code after it has been compiled (by javac) unlike C.

like image 555
535441434B Avatar asked Aug 14 '26 11:08

535441434B


1 Answers

JAVA is 'Write Once Run Anywhere'

Check the link,It will make you clear about the whole process on which java works How is Java platform-independent when it needs a JVM to run? After the compilation,the code actually have to go through an intermediate state that is called as the bytecode.This bytecode is then taken up by the JVM present on the machine and then is converted into the form that is executable by the machine.enter image description here

The JVM for every different platform is different,But the bytecode generated by the compiler is same everytime.The JVM performs the function of handling the bytecode and producing executable code in the form as is understood by the platform on which you are working on.This is the reason that java is called as "Write Once Run Anywhere".

like image 60
nobalG Avatar answered Aug 17 '26 00:08

nobalG



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!