I'm little confused here, does the JVM represents the bytecode (generate it) or it's just it load the compiled .class files (bytecode) into memory?! or JVM is just specifications to run the bytecode in a platform independent way?! thank you very much.
The JVM either interprets the byte code, i.e. it looks up the things to do on the hardware for each opcode in some internal data structure, or it compiles the byte code to real machine code and simply calls the compiled code when a Java routine is called.
The JVM is what takes the bytecode and translates it into machine code. The point of bytecode is that you get better performance than a strictly interpreted language (like PHP for example) because the bytecode is already partially compiled and optimized.
Sun JVM is written in C and Oracle JVM is written in C++
Java compiler javac converts source code into bytecode. JIT Compiler and Java Interpreter inside JVM convert the bytecode into corresponding machine code.
In java, only the source code(.java files) and bytecodes(.class files) are available. And we can't save the machine codes(.exe files) as because .exe files can only be formed at Run Time and vanished from RAM as soon as the program is executed completely.
In our system both the javac.exe(for compiling java source code, eg: javac HelloWorld.java) and java.exe(for executing java bytecode by JVM, eg: java HelloWorld) are called, which are available in .exe formats only(javac.exe and java.exe). So the Java Compiler javac and JVM were not written in Java.If those were written in Java then those might have been available in javac.class and java.class format.
javac comes under JDK and not under JVM.Remember,JVM only works during Run Time means after the compilation of Source Code into Byte Code..but before that javac compiles the source code into byte code. JVM converts bytecode into corresponding machine code by JIT Compiler and Java Interpreter.
For different Operating Systems different JDK and JRE softwares are available by Oracle Corporation; So both the JVM(coming under JRE) and javac Compiler(coming under JDK) are Platform Dependent.So it is confirmed that javac Compiler and JVM are not written in Java.Because Java language is always Platform Independent.
The Java compiler (javac) turns your human-readable code into bytecode, which is then running in a JVM.
From the oracle docs:
A program has to be converted to a form the Java VM can understand so any computer with a Java VM can interpret and run the program. Compiling a Java program means taking the programmer-readable text in your program file (also called source code) and converting it to bytecodes, which are platform-independent instructions for the Java VM.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With