Chapter 9. Inside a Java class File

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 

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 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 Once, Run Anywhere" promise of Java.

The DumpClass program, provided with this book and detailed in appendix B.3, provides a byte-by-byte disassembly of a class file. This chapter examines the output of the DumpClass program on the hello.class file to explore the concepts of the class file in more depth.

Programming for the Java Virtual Machine
Programming for the Javaв„ў Virtual Machine
ISBN: 0201309726
EAN: 2147483647
Year: 1998
Pages: 158
Authors: Joshua Engel

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: