Page 56 - iPro_trackGPT_V5_Class8
P. 56

Compiling and Running a Program

                  When we compile a Java program, the Java compiler converts it into bytecode. This bytecode
                  is a platform-independent code which can run on any machine without making a single
                  change. A Java compiler is a program that translates the source code written by us into
                  machine-readable code.
                  To compile and run a program, follow the given steps:











                                1  Click on the Compile button.

                  If your program is successfully compiled, a message Class compiled – no syntax errors will
                  appear at the bottom of the code editor window.








                                                                            2  Right-click on the
                                                                           HelloWorld class icon.
















                              3  Select the void main (String[] args) option.
                                                                                   4  Click on the OK button.

                  The output of your program will appear in the Terminal Window as:
                                                                            Tech Tweak

                                                                      If  you  want  to  make  any  changes  to  a
                                                                      program,  then  double-click on the class
                                                                      icon and make the required changes. After
                                                                      making the required changes, you need to
                                                                      compile the program again.


                     STRUCTURE OF A JAVA PROGRAM

                  In the previous section, we created a program with a class called HelloWorld, which is defined
                  using the class keyword. The curly brackets ({ }) mark the beginning and end of the class body.


                    54    TrackGPT iPRO (V5.0)-VIII
   51   52   53   54   55   56   57   58   59   60   61