5 Phases of the Java Program

5 Phases of the Java Program | There are five phases needed to run the Java program. In this section, we will discuss those 5 phases of the Java program in detail.

These steps are to create and execute the Java application using a Java development environment. These phases are discussed in the context of JDK 6.0 from Sun Microscystems Inc. Sun Microsystems Inc. is an American technology company that has sold computers and also has given many information technology services, this company has created java programming language and the Solaris operating system, Virtual Box, Network File System, and SPAC Microprocessors and many more.

JDK is the Java Development Kit and JDK6 is the version 6th version of JDK, this is the distribution of java by oracle corporation it implements (JLS) Java Language Specification and (JVMS) Java Virtual Machine Specification and this provides the Java Application Programming Interface(API). The first version of JDK is JDK 1.0 released on 23 January 1993.

The 5 Phases of the Java Program are as follows:-

  1. Edit
  2. Compile
  3. Load
  4. Verify
  5. Execute

Observe the below diagram for the 5 Phases of the Java Program:- 

5 Phases Of the Java Program

Let us see in detail the 5 Phases of the Java Program:-

Phase-1: Edit

When we write a Java program on any editor & save it, then it is stored in a disk with an extension of .java. This .java file is platform-independent therefore a Java program (.java file) written in one operating system can be used in any operating system.

Phase-2:  Compile

The compiler’s work is to convert the high-level language to bytecodes then store it with an extension of .class. To compile we use the “javac” command.

After developing the Java program, we compile it through the “javac” command. The compiler checks for syntax errors, and if everything is correct then it starts translating the .java file else it gives a compile-time error. After compilation of the .java file, the .java file is translated to .class file. Similar to the .java file, the .class file is also platform-independent.

Phase-3: Load

The class loader reads the code, compiles it, and puts those bytecodes from the disk to primary memory. From the class loader, the codes are stored in primary memory. 

When we execute the “java” command to run the Java application then the .class file (which contains bytecode) is loaded into the RAM, and this task is done by the class loader.

Phase-4: Verify

This step confirms that the bytecodes are valid and make sure that they do not risk the Java security restrictions. 

Phase-5: Execute

In this step, the JVM (Java Virtual Machine) reads the byte and translates it to the language that the machine can understand that is machine language then executes the program and stores it in values in primary memory. This machine language will be different for different operating systems.

If you enjoyed this post, share it with your friends. Do you want to share more information about the topic discussed above or do you find anything incorrect? Let us know in the comments. Thank you!

Leave a Comment

Your email address will not be published. Required fields are marked *