Page 177 - PowerPoint Presentation
P. 177

CAVITE STATE UNIVERSITY
                               T3 CAMPUS
                               Department of Information Technology          COSC 65 – Programming Languages

                       -   Then paste it in the variable value (C:\Program Files\Java\jdk1.8.7_00\bin;
                          C:\Program Files\Java\jre1.8.0_77\bin)
                       -   Then add a semicolon and a dot at the end of the copied address. (C:\Program
                          Files\Java\jdk1.8.7_00\bin; C:\Program Files\Java\jre1.8.0_77\bin;.)

                       How to set Permanent Path of JDK in Windows 8 & 10
                       -   Go to Control Panel
                       -   Go to System and Security
                       -   Click the System
                       -   Click the Advanced System Settings
                       -   Go to Environment Variables
                       -   Go to System Variables
                       -   Click the variable Path
                       -   Copy the address/location of your Java (C:\Program
                          Files\Java\jdk1.8.7_00\bin)
                       -   Go back to the Edit System Variable
                       -   Don’t delete the existing path
                       -   In the Variable value: add to the end of the variable value a semicolon (;)
                       -   Then paste the copied address/location next to the semi colon
                          (existing_path_etc;C:\Program Files\Java\jdk1.8.7_00\bin;
                       -   Then go to the JRE bin folder, copy the address/location
                       -   Then paste it at the end of the Variable value. (existing_path_etc;C:\Program
                          Files\Java\jdk1.8.7_00\bin;C:\Program Files\Java\jre1.8.7_00\bin;)
                       -   Click OK until everything is closed.
                       -   Open a command prompt, then type javac. It must show all the available path.
                       -   Then open again the Advanced System Settings
                       -   Go to Environment Variable
                       -   On the User variables
                       -   Click New Button then
                       -   Set the Variable name as JAVA_HOME (Variable name: JAVA_HOME)
                       -   Set the Variable value the path of jdk folder. (Variable value: C:\Program
                          Files\Java\djk1.8.7_00)
                       -   Then Click Ok until everything is closed.

               First Java Program (Hello World!)
               Let’s create the hello java program:
                                                                                  NOTE: You can use
                         class HelloWorld {                                       Jvdroid on mobile
                                public static void main(String[] args) {          phone. Just download
                                       System.out.println( “Hello World!”);       it on playStore.
                         }
                         }

               save this file as HelloWorld.java

                       To compile:   javac HelloWorld.java
                       To execute:  java HelloWorld

               Compilation Flow
                       When we compile Java program using javac tool, java compiler converts the source
               code into byte code.

                                     Java Code               Compiler                Byte Code


                                  HelloWorld.java                                 HelloWorld.class

                                                                                                 Page | 36
   172   173   174   175   176   177   178   179   180   181   182