Page 24 - CTS - CSA TP - Volume 2
P. 24

COMPUTER SOFTWARE APPLICATION - CITS




           Step 2.2:  Define the Main Method:
           •  Inside the class, define the main method. This method is the entry point for Java programs.











           Step 2.3: Print “Hello” to the Console:
           •  Within the main method, use the System.out.println() statement to print. “Hello” to the console.









           Step 3: Save the File: Save the file with the name Hello.java.(Filename should be the class name )

           Step 4: Compiling the Java Program
           1  Open Command Prompt (cmd):
              Press Win + R, type cmd, and press Enter to open the Command Prompt.
           2  Navigate to the Directory:
              Use the cd command to navigate to the directory where Hello.java is saved. For example:













           3  Compile the Java File:
              In the Command Prompt, type the command   javac filename.java and press the Enter key











              If there are no syntax errors in your code, the Java compiler (javac) will create a file named Hello.class in the
              same directory.
           Step 5: Running the Java Program

              After successfully compiling the program, run it using the java command:












                                                            9

                               CITS : IT & ITES - Computer Software Application - Exercise 80
   19   20   21   22   23   24   25   26   27   28   29