Home   |   About   |   Terms   |   Contact    
Read & Learn
 

What is .class file in Java?

Java

☯ All Java Articles     ☯ All Articles


A new product.






Popular Google Pages:




This article is regarding What is .class file in Java?
Last updated on: .



◕ What is .class file in Java?

- Let we have a Java Program like:

public class birds{
public static void main (String args[]){
system.out.println("Blue Sky!");
}
}

We save this program with the file name newProgram.java.
If we compile and run this program then we will get a file in the same directory by the name birds.class.
This file comes due to the compiler and it is very important.

The reason is, when we run our program then the compiler generates a bytecode program that is the equivalent of our source code file newProgram.java. The compiler stores the bytecode program in a file with the same name as the Class Name of the source code file, but with the extension .class. Here it is birds.class.
And this .class file plays the main rule to run the Java program.

Because, to execute our Java program, the Java interpreter executes the bytecode instructions from this .class file.

As this bytecode program does not depend on any machine, hence the same Java Program can run on any machine which contents Java. As a result our Java program is completely portable. Hence we can save lot of time, effort and many other things with the help of Java.

By default, the .class file is stored in the same directory where the source file is.

How to run the .class files?



Related Java articles:
What is Java? Where we can apply Java?
Why Java is a Machine Independent Program? What is Machine Independent Program?
Root Directory of Java
How to Compile and run a Java Program?





Popular Google Pages:





Top of the page

Amazon & Flipkart Special Products

   


Top of the page