Home : Course Map : Chapter 1 : Java :
The Java Procedure
JavaTech
Course Map
Chapter 1
Introduction
History
What is Java?
Versions
Java 5.0
Features

Java Process
Tools
Documentation
Compatibility
Getting Started
Simple Applet
Simple Application
Starters
Exercises

    Supplements
Interpret/Compile

Making WebPages
Plug-in
Java 5.0 Features
The JVM
Advanced JVMs
Alt. Compilers
Alt. JVMs
Java Deployment

     About JavaTech
     Codes List
     Exercises
     Feedback
     References
     Resources
     Tips
     Topic Index
     Course Guide
     What's New

The essential steps to creating and running Java programs go as follows:

  • Create a Java source code file
  • Compile the source code
  • Run the compiled code in a Java Virtual Machine.

The following figure illustrates these steps:


Figure J.1.1: Steps for creating and running a Java program.

You create the code with a text editor and save it to a file with the ".java" suffix. All Java source code files must end with this type name. The first part of the name must match the class name in the source code. In the figure the class name is Test so you must therefore save it to the file name Test.java. We will discuss what class actually means in later chapters.

With the javac program, you compile this file as follows:

C:> javac Test.java

This creates a bytecode file (or files if the code file included more than one class) that ends with the ".class" type appended. Here the output is Test.class.

The bytecode consists of the instructions for the Java Virtual Machine (JVM or just VM).

The JVM is an interpreter program that emulates a processor that executes the bytecode instructions just as if it were a hardware processor executing native machine code instructions.

Note: There are now Java processors that directly execute the byte codes directly in hardware. See Chapter 24.

The platform independence of Java thus depends on the prior creation of JVMs for different platforms.

The Java bytecode can then run on any platform in which the JVM is available and the program should perform the same. This Write Once, Run Anywhere approach is a key goal of the Java language.

Note: For applets the JVM runs inside the browser.

References & Web Resources

 

Latest update: Oct. 10, 2004

            Tech
Java in Science
    & Engineering
Benefits
Shortcomings
RealWorld Examples

           Physics
Java in Physics
SimulationTypes
Simulate&Analyze
Sim. in Experiments
  Demo 1: Event
  Demo 2: Continuous
  Demo 3: Static

Learn by Coding
Exercises

  Part I Part II Part III
Java Core 1  2  3  4  5  6  7  8  9  10  11  12 13 14 15 16 17
18 19 20
21
22 23 24
Supplements

1  2  3  4  5  6  7  8  9  10  11  12

Tech 1  2  3  4  5  6  7  8  9  10  11  12
Physics 1  2  3  4  5  6  7  8  9  10  11  12

Java is a trademark of Sun Microsystems, Inc.