Java programs are made out of classes. 

You start by writing in a file using a file editor. 

We start with Notepad. Later we will use DrJava and BlueJ. 

In Notepad you define your classes. 

Save them as .java files.

Compile them: with javac you transform them in bytecode. 

With java (Java virtual machine) you run the bytecode. 

So let me write a program for you on this system.

This system? Is that silo? Is that the Windows machine I am using?

Let me do it on Windows first. 

Classes usually contain variables and methods. 

Variables and methods are called members. 

Members can be static or non-static. 

So we create Program.java on the Desktop with this contents:

class Program { 
  public static void main(String[] args) {
    System.out.println("I am here."); 
  } 
}

What does void really mean? 

Let's finish the compile/run experiment first:

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\dgerman>dir Proggram.java
 Volume in drive C has no label.
 Volume Serial Number is BA71-C62D

 Directory of C:\Users\dgerman

File Not Found

C:\Users\dgerman>dir
 Volume in drive C has no label.
 Volume Serial Number is BA71-C62D

 Directory of C:\Users\dgerman

01/09/2013  09:28 AM    <DIR>          .
01/09/2013  09:28 AM    <DIR>          ..
01/08/2013  10:18 PM    <DIR>          .android
11/01/2012  09:50 PM    <DIR>          .datastudio
01/09/2013  09:28 AM    <DIR>          Contacts
01/09/2013  10:11 AM    <DIR>          Desktop
01/09/2013  09:28 AM    <DIR>          Documents
01/09/2013  09:28 AM    <DIR>          Downloads
01/09/2013  09:29 AM    <DIR>          Favorites
01/09/2013  09:28 AM    <DIR>          Links
01/09/2013  09:28 AM    <DIR>          Music
01/09/2013  09:28 AM    <DIR>          Pictures
01/09/2013  09:28 AM    <DIR>          Saved Games
01/09/2013  09:28 AM    <DIR>          Searches
01/09/2013  09:28 AM    <DIR>          Videos
08/14/2012  06:13 PM    <DIR>          workspace
               0 File(s)              0 bytes
              16 Dir(s)  122,170,318,848 bytes free

C:\Users\dgerman>cd Desktop

C:\Users\dgerman\Desktop>dir
 Volume in drive C has no label.
 Volume Serial Number is BA71-C62D

 Directory of C:\Users\dgerman\Desktop

01/09/2013  10:11 AM    <DIR>          .
01/09/2013  10:11 AM    <DIR>          ..
01/09/2013  10:11 AM               109 Program.java
               1 File(s)            109 bytes
               2 Dir(s)  122,170,318,848 bytes free

C:\Users\dgerman\Desktop>dir Program.java
 Volume in drive C has no label.
 Volume Serial Number is BA71-C62D

 Directory of C:\Users\dgerman\Desktop

01/09/2013  10:11 AM               109 Program.java
               1 File(s)            109 bytes
               0 Dir(s)  122,170,318,848 bytes free

C:\Users\dgerman\Desktop>javac Program.java
'javac' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\dgerman\Desktop>"C:\Program Files\Java\jdk1.6.0_33\bin\javac.exe" Progr
am.java

C:\Users\dgerman\Desktop>"C:\Program Files\Java\jdk1.6.0_33\bin\java.exe" Progra
m
I am here.

C:\Users\dgerman\Desktop>PATH=%PATH%;"C:\Program Files\Java\jdk1.6.0_33\bin"

C:\Users\dgerman\Desktop>javac Program.java

C:\Users\dgerman\Desktop>java Program
I am here.

C:\Users\dgerman\Desktop>

class Program { 
  public static void main(String[] args) {
    System.out.println("I am here."); 
    System.out.println( 1 ); 
    System.out.println( 2 + 5 ); 
    int n = 2 + 5; // n is a local variable, local to main
    System.out.println( n ); 
    System.out.println( n - 3 ); 
    System.out.println( Math.sqrt( n ) ); 
    double m = Math.sqrt( 6 ); 
    System.out.println( m ); 
  } 
}

The lab will give you many more examples. 

In particular it will demonstrate I/O and Strings. 

Let's define a method that returns a value:

class Utilities {
  public static double sqrt(double value) {
    double lo = 0, hi = value; 
    double guess = (lo + hi) / 2; 
    while (hi - lo > 0.0000001) {
      double test = guess * guess; 
      if (test  == value) {
        break;
      } else if (test > value) {
        hi = guess; 
      } else {
        lo = guess;
      } 
      guess = (hi + lo) / 2;
    } 
    return guess; 
  }
}

class Program { 
  public static void main(String[] args) {
    System.out.println("I am here."); 
    System.out.println( 1 ); 
    System.out.println( 2 + 5 ); 
    int n = 2 + 5; // n is a local variable, local to main
    System.out.println( n ); 
    System.out.println( n - 3 ); 
    System.out.println( Math.sqrt( n ) ); 
    double m = Math.sqrt( 6 ); 
    System.out.println( m ); 
    System.out.println( Utilities.sqrt( 6 ) ); 
  } 
}