Home Java What is Java class File?

What is Java class File?

652
0
java byte code

In previous article we learned how to Write your first Java program.

Java class file is a file that contains Java bytecode and having .class extension. A Java class file is created by a Java compiler from .java files after successful compilation. If a .java file (source file) has more than one class then each class will compile into separate class files.

Let us take an example, save the following code as HelloWorld.java

public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World!"); 
    }
}

Compile the above command with javac command

hello world

After successful compilation a new file is created HelloWorld.class.

class file

When you open this file you will see byte code.

byte code

So, with the help of byte code Java is able to achieve platform independence.

To download Java click here.

This site uses Akismet to reduce spam. Learn how your comment data is processed.