Java phases or Executing steps

Java programming is one of the most popular programming languages in the world. In the previous articles, we have explained the introduction to java programming. In this Java programming session, you will get a complete Java tutorial. Naturally, in this article, we will explain the Java phases or Executing steps.

Before that, we would like to remind you that a computer does not understand ordinary language. It has its understandable language, which is known as binary numbers. It’s all about on and off. Based on this concept, all the programming languages perform some execution steps to get the final result.

Java phases or Executing steps

Similar to other programming languages, Java programming also has some executing steps or phases. Phases are the steps of finalizing a  complete output. For example, if you want to make pudding, first you need to collect the ingredients. Second, you have to check if the elements are okay or not. Third, You have to mix them properly one after another. And finally, you put that mixture in the oven. After all, you get a pudding.

Therefore, the Java compiler also performs similar phases or steps to get a final object code. These phases are known as “Java phases” or “Java executing steps.” There are five Java executing steps. They are,

  • Typing and Editing
  • Compiling
  • Loading
  • Verification
  • Execution

Each of the phases has different execution formalities. Let’s have a glance at the following explanations for each of the execution steps.

Java phases or Executing steps

Typing and Editing

First, we must type our expected Java programming on any of the typing and editing platforms. Generally, there are lots of Java programming software that are there on the internet to help you do all these five phases. Except for the java compiling software, you can type on a text editor or any other editing software.

Let’s say your first Java programming file is firsttest.java. You wrote your first program in this file. Now the text editor will save your data in the hard disk of your computer. This firsttest.java is our source code. Hard disk stores all the data you require to compile your written program. Later on, whenever it is necessary, your hard drive can access your file from the directory anytime.

Compiling

Now, the language you entered is a Java language. This language is not understandable to the machine. Therefore, to make it acceptable, we must compile and interpret our Java code. To assemble the firsttest.java document, we can use any of the Java compiling software. Therefore it can convert the file to the bytecode.

Compile error is one of the issues here to consider. A compile error is a kind of error occurs if there is any compilation running in the background. In an easy word, If the program is already running in the RAM, this error usually occurs. Therefore, before we compile our java file, we must check if the same page is loading or not.

Bytecode is a form of instruction that is the constants, numeric code, or references encode the result of compiler parsing. In an easy word, the computer can not understand the direct Java code but the bytecode. Therefore, Java compiling software first converts the Java code into the byte code. And then do the next steps.

However, The compiler converts your firsttest.java into to the firsttest.class file, and it is saved in the hard disk too. So, the RAM can access it at any time necessary. But if there is any mistake in the firstest.java, then it will show the error while compiling the java file. If no error, then it will compile directly to the bytecode. It is an intermediate code.

Loading

From this stage, the interpretation works. Here, we will need a JVM (Java virtual machine). You can manually install this JVM on your computer. Remember that, before you introduce to your eclipse on your computer, if you didn’t have JDK installed on your PC, you will be required to complete this installation first. Otherwise, you will not be able to install the eclipse.

However, in this stage, the interpretation starts its action. The class loader needs to access the firsttest.class file. The class loader access from the hard drive and passes the information to the RAM. Therefore, the class loader accesses both the hard drive and the random access memory.

Verification

The verification stage is the essential phase for Java execution. In this stage, JVM checks if there is any unwanted code in the bytecode or not. Unwanted codes can be virus code or any, other than the granted input. Java checks the bytecode file for security reasons.

Therefore, other than the granted codes, this verification step will not allow any of the bytecodes. If there have any, it will ask the operator to consider that part and compile again. Moreover, it will show the error place so that the operator can easily find out the mistakes. If everything goes well, JVM will proceed to the Execution stage. 

Execution

At this stage, the JVM will execute the final bytecode into the object code. If there has any runtime error, you will have to recompile the java code. A runtime error is a primary issue here we need to consider. If the program is already running in the background, then this runtime error will occur.

If there is no runtime error, the execution phase will run the granted bytecode into the object code. And the operator can enjoy the output. This stage doesn’t check if there are any unwanted codes in the file or not. Its main task is to execute the granted program.

Summery

Let’s summarize the overall Java phases or Executing steps. First, you have to type your code on any typing or editing software, e.g. text editor. And then you have to compile your java code into the bytecode. Because you know the computer can only execute the bytecode. Third, you need to use any Java virtual machine to perform the interpretation stages. It includes loading the bytecode, verification, and execution. After all, we can see your result on the screen.

These five stages are the essential phases of Java compilation and interpretation. If you are interested to learn Java programming, you must understand these phases because it is the basic building block of java development.

This Post Has One Comment

Leave a Reply