Chapter 9. Inside a Java class File

Your first Java program probably looked something like this:

public class hello
{
   public static void main(String argv[])
   {
      System.out.println("Hello, world");
   }
}

You ran it through the Java compiler

> javac hello.java

to create the file hello.class. Then you ran the program

> java hello
Hello, world
>

and exulted in having mastered another programming language.

The hello.class file contains a Java virtual machine bytecode class that produces the intended effect of hello.java. The file hello.class is called a class file. The class file format is described in chapter 4 of The Java Virtual Machine Specification. All JVM implementations are required to treat this file in the same way. This is the heart of the “Write ...

Get Programming for the Java™ Virtual Machine now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.