we write code in a high-level language which is human understandable language.
which is not understood by machines so the machine uses a compiler to convert
the code from high level to machine level or low-level code.
if we take other languages like c and c++
the machine-level code differs by programming language and operating system.
i.e.,
c and c++ generate a .exe file that is not the same for two machines if they are
running on a different os(operating system)Linux and windows.
i.e., when c and c++ files get compiled they generate the .exe file which is a directly executable file, and these are built or generated on a particular os only
and for their execution, they will have a system call on the same os.
so if we compile the files in one os and execute them on other can't be possible in these languages.
if you compiled c and c++ files in one os you should execute those files on the same os i.e, machine-level code differs by each operating system.
so these are platform-dependent.
whereas java is different from these languages
When we compile the java file by the command “javac filename.java” creates an intermediate code called Bytecode.
bytecode is independent of the platforms.
This is where java makes difference between all different programming languages.
It creates a .class file, which is considered bytecode. Whereas languages
like c and c++ will create an executable code when they are compiled and thus makes them platform dependent.
and This byte code is not executable. We need a translator for executing this bytecode.
And JVM does this job. Generally, JVM resides in the main memory of our computer.
JVM acts as an interpreter and executes the bytecode generated by the compiler.
No comments:
Post a Comment