Page 32 - CA_Blue( J )_Class9
P. 32

2.2.2 Java Applet
                  Applets are Java programs which are downloaded from a website on a client computer and can only be executed
                  within a web browser. They cannot run independently on a computer like standalone applications. Java Applets
                  are used for Internet programming, creating animation and games. They are also called Internet Applets.

                       2.3 JAVA COMPILATION PROCESS
                  Java is a platform-independent programming language, which means that Java code can run on any platform (such
                  as Windows, Linux, macOS) without modification. This is achieved through the following steps:

                  Step 1:  The program code is compiled into bytecode through an Operating System independent compiler.
                  Step 2:   This bytecode needs to be converted into machine code to execute on an individual device. This is done by
                         Java Virtual Machine. The Java Virtual Machine performs all the tasks of the Java runtime system. It loads
                         the Java class file and interprets the compiled bytecode.











                  As you know, compiler translates High level language program to a lower-level language to create an executable
                  program and  Interpreter  reads the input  source  program and  then translate to machine  code instruction  by
                  instruction.

                  2.3.1 Java Compiler
                  Java Compiler converts the source code written in Java (with the .java extension) into an intermediate code called
                  byte code. The Java Compiler is also known as javac.
                  Java bytecode further is converted by Java Virtual Machine to machine-dependent code.

                  This bytecode has resemblance with Assembly language. The only difference between Byte code and Assembly
                  language is that byte code is used by JVM and Assembly language is directly used by the hardware (CPU).


                        Note: The extension of Java source code is .java and the converted bytecode has the extension .class.



                  2.3.2 Java Virtual Machine (JVM)
                  Java Virtual Machine converts Java bytecode to machine code so that it can be executed. Also it can run on any
                  operating system. It follows the principle of “Write Once, Run Anywhere”. It manages and optimises the program
                  so that memory usage can be minimised.  The Java Programs written by programmers are called Java Source
                  Code. They are saved with the extension .java. When Java Source Code is compiled by Java Compiler (javac), the
                  resultant code is called Java bytecode which is further converted by JVM to machine code.

                                                                                                Interpreter
                                                                                 JVM             for Mac

                           Source Code        Complier          Byte Code                       Interpreter
                            (.java file)       (Javac)         (.class file)     JVM           for Windows

                                                                                 JVM            Interpreter
                                                                                                 for Linux


                    30    Touchpad Computer Applications-IX
   27   28   29   30   31   32   33   34   35   36   37