Home : Course Map : Chapter 1 : Java :
A Simple Java Application
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 procedure to create and run a standalone program, called an application in Java, goes as follows for a program that simply prints "Hello World!" to the command console:

Step 1: Use an editor to enger the following code for the HelloWoldApp program:

HelloWorldApp Application

public class HelloWorldApp
{
  public static void main(String arg[])
  {

    System.out.println("Hello World!");
  }
}

 

Save this code code in a file called HelloWorldApp.java

Step 2: Compile the application with the command line*:

    > javac HelloWorldApp.java
This creates the class file (with the bytecode output):
    HelloWorldApp.class
Step 3: Use the java command to run the program:
    > java HelloWorldApp
    Hello World!

The output is printed after the command line.

We will discuss in coming chapters the structure of the program, the class keyword, and other elements of a Java program.

 

* On the Java Tools page, see the note on the javac -target option.

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.