DEV Community

Cover image for How Java Works? 🚀

Posted on • Updated on

How Java Works? 🚀

Image description


  • Java source code is written in human-readable form by developers. This source code typically resides in files with a .java extension.
  • The Java compiler (javac) translates the source code into platform-independent bytecode. Bytecode is a set of instructions for the Java Virtual Machine (JVM) and is stored in files with a .class extension.

2.Java Virtual Machine (JVM):

  • The JVM is a virtual machine that provides an execution environment for Java bytecode.
  • When a Java program is executed, the JVM loads the bytecode files generated by the compiler.
  • It then interprets the bytecode instructions and translates them into native machine code instructions that are specific to the underlying hardware and operating system. This translation can be done dynamically during program execution using techniques like Just-In-Time (JIT) compilation.
  • The JVM also manages memory allocation and deallocation, garbage collection, exception handling, and other runtime tasks.


  • Once the bytecode is loaded and translated by the JVM, the Java program begins execution.
  • The JVM follows the instructions provided by the bytecode, executing the program's logic step by step.
  • Java applications can interact with the underlying system through APIs provided by the Java standard library and other libraries.

Top comments (0)