Compilation and Interpertation Process
javac (compiler) java(interpreter)
high level code - > compile - > bytecode - > interperted - > machine code
Bytecode is intermediate code generated by compiler, this is same will be for all the systems/computers
that is why our java is portable and independent programming language.
COMMAND TO EXECUTE PROGRAM ON COMMAND PROMPT
ASSUMING WE CREATED A JAVA PROGRAM WITH CLASS NAME Calculator.java
1. javac Calculator.java // compilation is beginning, compiler generates bytecode, at once the code is compiled.
BYTECODE FILE IS SAVED AS .CLASS, for above example the file that is created is Calculator.class
2. java Calculator // interpertating is beginning, result will be generated, each and every line is checked and interperted(one - by - one)
JDK vs JRE vs JVM
JDK(JAVA DEVELOPMENT KIT) --> It holds jre, tools for the development of java application like compiler, interpreter,etc. It has physical existence in our machine.
JRE(JAVA RUNTIME ENVIRONMENT) --> it holds JVM + Java libraries and is physically present in our system.
JVM(JAVA VIRTUAL MACTINE) --> it is a virutal machine that helps to load code, verify code, and execute code.