How Java Program Works In Details Step By Step


Step 1: Write Java Program.

Step 2: Compile java file to class file and generate byte code.

Step 3: Byte code translate to machine code and run on JVM.


                  


                   





Steps to write, compile and run java program using command prompt.

     (i). Save the program. After using a text editor, such as NotePad, to create your Java program, save the program with a .java extension.


(ii). Open Command Prompt.
(iii). Navigate to the correct folder.
(iv). Set path.
(v). Compile the program.
(vi). Run the program.



Create class as Demo and save as Demo.java in correct folder.Class name and file name should be same.

public class Demo {

public static void main(String args[]){
System.out.println("First java program is successes");
}

}








Set path in Java

Right click on My computer and click on  properties option.




Click on Advanced system settings.

Java Home Path in Enverionment Variable



Click on Environment Variables.






Set JAVA_HOME (to java home path)

Example:  C:\Program Files\Java\jdk1.8.0_111




Set PATH(Path to Java bin directory)

Example:  C:\Program Files\Java\jdk1.8.0_111\bin



Compile the program with command javac Demo.java




Run the program in command prompt 

Example: java Demo(Class name)

Output will be showing on command prompt on press enter button after writing the run command.




3 comments:

  1. Very good tutorial. I have prepared this tutorial, its helped me to increase my java knowledge in details.

    ReplyDelete
  2. Excellent Post. Are you looking for Laptops for your training? Click here Laptop Price to select your idle Laptop in budget.

    ReplyDelete
  3. Excellent Post. Are you looking for Laptops for your training? Click here Laptop Price to select your idle Laptop in budget.

    ReplyDelete