File Extension CLASS
File extension CLASS is used to denote a compiled Java source code file. Prior to compilation, Java files are stored in plaintext with the JAVA file extension. In order to run Java programs, the source code must be compiled to create a CLASS file, which can then be loaded into a Java Virtual Machine to execute the application. Many Java applications will make use of multiple classes, each of which is stored and loaded as an individual CLASS file.
Before executing an application written in Java, it must first be compiled. This process converts the plaintext source code of the application into bytecode, which is a set of instructions designed to be executed by a software interpreter, which in this case is the Java Virtual Machine (JVM). Unlike JAVA source files, CLASS files are not human-readable if opened using a text editor.
Java is a cross-platform compatible language, meaning that the bytecode produced by compiling a program on one platform will be able to run on the Java Virtual Machine of any other platform.
A CLASS file contains several separate sections including access flags, constants, classes, interfaces and methods. CLASS files are used by a Java program to create objects and define their behaviour. However, as CLASS files are run as part of an executable program, they should only be loaded into a JVM if they are from a known, trusted source as the program could potentially be malicious software.
CLASS files can be loaded and run on any platform which has a Java Virtual Machine. Alternatively, some CLASS files can be decompiled into their original, human-readable source code and opened with a standard text editor or development environment. However, in most cases the reverse engineering of compiled software is illegal, and whether or not decompiling the code for educational use is allowed will depend on the license and usage terms attached to the program.