First, write the Java code and save it to your hard drive. Then, on the command line, enter:
Javac Classname.java
At this point, the Java class file is compiled into a byte-code (. Class) file. If you use IDE development tools such as Eclipse, then when you save the code, these development tools have done the manual compilation above, so you can see the class file in the corresponding directory. At this point the class file is still saved on the hard drive, so you have to write:
Java ClassName//To execute this Java class
The JRE will now read the class file from the hard disk and load it into the memory area allocated to the JVM by the system-runtime data areas. Then the execution engine interprets or compiles the class file, translates it into a specific CPU machine code, and finally the CPU executes the machine code, thus completing the process.
Java Program execution Process