Contents:
- What is Java Source Code?
- Java Compiler
- What is Java Bytecode?
- JVM(Java Virtual Machine)
- Java compilation process involves conversion of human readable Java source code file into machine readable byte code which can be executed by JVM(Java Virtual Machine).
- The above process involves:
1. Writing of source code file
2. Invoking compiler
3. Bytecode generation
4. Translation of bytecode into something called native machine code and running the program by JVM(Java Virtual Machine).

What is Java Source Code?
- Computer Program written in Java programming language is called Java source code.
- First, we need to type our source code and must save it into a file with .java file extension.
- Now, we can call the above mentioned file, a Java source code file.
Java Compiler
- Java compiler is a software that checks for syntax errors in Java source code file and would not let convert your source code into bytecode until all the errors are removed from Java source code file.
- Java compiler is just like your language teacher who checks for grammatical mistakes found in your paragraphs.
- javac is the name of your Java compiler that should be invoked to compile Java source code.
- When Java compiler is satisfied that everything would run correctly, it creates a new document coded into Java bytecode.
- The new document made by compiler is bytecode file with .class file extension having file name same as your class name written in source code file.
What is Java Bytecode?
- Java bytecode is the compiled version of Java source code made by Java compiler.
- Java bytecode is the intermediate representation of Java source code which is not in native machine code and also not human readable.
- It lies somewhere between Java source code and machine code and that is why not directly executable by computer system.
- Java compiler creates separate bytecode file for all classes written in source code file having same name as your class name with .class file extension.
- Java bytecode is platform-independent means, any device capable of running JVM(Java Virtual Machine) can translate bytecode into native machine code irrespective of internal machine architecture and runs the program.
- So, in short, Java bytecode makes Java a platform-independent computer language.
Java Virtual Machine(JVM)
- Java Virtual Machine(JVM) is a software which translates Java bytecode into machine code that the underlying operating system and hardware understands.
- JVM provides run-time environment for the execution of Java bytecode instructions.
- JVM acts as a bytecode interpreter which interprets the bytecode and run the program.
- First of all, JVM loads the class which contains main() function because main() function is the standard starting point for execution of Java application.
- By typing java command, we start JVM to start the translation and execution process.
Happy Learning🙂