Object Oriented Programming - SCJ2153: Associate Prof. Dr. Norazah Yusof
Object Oriented Programming - SCJ2153: Associate Prof. Dr. Norazah Yusof
Saves on disk
Text Editor
If error
Produces
Java Compiler
Results
Program Execution
1. Create a new directory in drive C to place all your Java source files. 2. Open a text editor i.e. Notepad. 3. Type the Java code. 4. Save the code to a file. The name of the file must be the same as the class name and with the extension name .java.
3. 4. 5.
Compile the Java source file at the DOS prompt using the javac command. If there are syntax errors, the compiler will display the error messages and need to modify the program. If no error, a Java byte code file will be produced (i.e. class).
8
10
1. The Java source file can be run in DOS environment. 2. Run the Java source file at the Dos prompt using the java command. 3. The Java Virtual Machine (JVM) will interpret each lines of the Java byte codes and produces the results.
11
Demonstrate how to run the Java byte code file at Dos prompt
java HelloApp
12
13
This is Java main method. public class HelloApp Every Java application must { have a main method public static void main(String [] args) { This area is the body of the main method. All of the actions to be completed during the main method will be between these curly braces. } }
14
// This is my first Java program. public class HelloApp { public static void main(String [] args) { System.out.println("Hello there"); System.out.println("Welcome to Java"); } } This is the Java Statement that is executed when the program runs.
15