The classic first Java program:
public class Hello { public static void main(String[] args) { System.out.println("Hello World!"); } } |
A Java program file name must end in ".java"
The classic first C program:
main() { println("Hello World!"); } |
A C program file name must end in ".c"
The program file is now in human readable form and it is not executable by the computer.
This step has been automated and the tool used to translate human readable programs into computer executable programs is called a "compiler". (This step is called "compilation").
The command used to compile a Java program is:
javac your_program_filename.java
The computer executable program that results from the compilation process will be stored in the file named your_program_filename.class (called "executable object" file).
The command used to compile a C program is:
cc your_program_filename.c
The computer executable program that results from the compilation process will be stored in the file named your_program_filename (called "executable object" file).
In most common cases, the linking is transparant to the computer user.
Programs have been written that "mimic" the Java machine. Programs that mimic a machine are called "emulators". A program that emulates the Java machine is called a "Java Virtual Machine" or "JVM".
The program java is a JVM and is used to run Java object files in UNIX. So to run a Java object file, type:
java your_program_filename