How we create first program in Java

---How we create the first program in Java ---

1)  First, we check that Java is installed in machine or not

     go into c:/program files/Java/JDK/bin
                  c:/program files/Java/JRE/

2)  If this folder does not present then download Java software and install it

3)  Check Java environment path, open command prompt then type javac

if javac is not recognized as an internal or external command, operable program then java path is not set

4)  if path is not set then set path using following step

   4.1)   Right click on this PC ---> Properties ----> Advance System Setting ----> Environment Variable ---> new ---> 

Variable Name:-    path
Variable Value:-    C:\Program Files\Java\jdk1.8.0_121\bin

Click Ok ---> Ok --> Ok restart command prompt open command prompt type javac if javac description will be shown then Path is set.

5)  Open notepad  and Create Java Hello World Program

  class Classname

     public static void main(String args[])
           System.out.println("Hello World");


6)   Save this file using

7)  open command prompt   javac

8)  Execute Program using java Classname

Complete Program with explanation:-

class Hello
   public static void main(String args[])
         System.out.println("Hello World");



//class:  it is user define datatype which contains definition of an object using data member and member function. it is keyword hence it has declared in lower case

//public:-  access modifier which provides accessibility of main() from outside of the class

//static:-   modifier which is used to execute any method or variable without creating an object , it provides compile-time memory allocation

//void:-  It is a datatype which returns null

//String args[]:- it is String type array which is used to manage input operation using command prompt.

// main():-  It is the entry point method of java program without a main() program will compile but not execute.

//System:-  It is predefined class to manage input/output operation

//out:-  reference variable or static variable of PrintStream class

//println():-  It is the predefine() of PrintStream

Post a Comment


POST Answer of Questions and ASK to Doubt

Post a Comment (0)