Configuration

Night mode

Java Class File

Java Basics Course

Engineers From These Top Companies and Universities Trust EXLskills

1M+ Professionals | 100+ Institutions

This is the EXLskills free and open-source Java Basics Course. It guides learners via explanation, demonstration, and thorough practice, from no more than a basic understanding of Java, to a moderate level of essential coding proficiency.

Is this course FREE?

Yes, this a 100% free course that you can contribute to on GitHub here!

Have more questions?

Java class and source file

Java Class File

Although you do not have to directly edit, build, or prepare class files manually in Java, we will still take a look at what the class file is and what it does. In its simplest definition, a class file contains the Java bytecode and has a ".class" extension. This file is what the Java Virtual Machine (JVM) interprets and converts into machine code. The class file is used by the JVM and not meant for your specific operating system.

Every time you run a Java program, the Java compiler creates a .class file from the Java source code file. The Java Virtual Machine then loads the .class file and executes the main method, which is the entry point for the Java application. This is one of the reasons why it is absolutely necessary to have a main method for classes where you have executable code. However, don't worry about making this mistake - another benefit of Java is the security protocols in place that verify each Java class file after loading and rejects class files that disobey the restrictions of the Java programming language.

Even though you could edit the .class file directly with text editors, it is not recommended because changes in the file will generate errors when you run the program.