Tuesday 27 September 2016

How to Compile And Run Programs In Core Java


Step-1: Right click on Desktop and select New option and then click on Shortcut.


Step-2: Write CMD in text box. Then click on Next.


Step-3: Write JAVA as name of shortcut file. Then, Click on Finish.

Step-4: Open Notepad or any text editor in your computer.

Step-5:Write following program in text editor-
                               
                                 class Hello
                          {  
                               public static void main(String args[])
                               {  
                                  System.out.println("Hello Java");  
                               }  
                           }
Description Of Program=>
Hello is class name. public static void main(String args[]) method is called main method. System.out.println("Hello Java"); statement is used to print any line.
Step-6:Make new directory to save java files of any name. For example, I create directory JAVA_PROGS.

Step-7:Save this file as Class_Name.java. In our example, Class name of file is Hello. So, we save this file as Sample.java in directory JAVA_PROGS.

Step-8: Right click on JAVA shortcut and click on Properties.


Step-9: Copy path you are saving programs of java and paste it to Start in label. In our example, directory is JAVA_PROGS. I copy path and paste it to Start in label.

Step-10: Start JAVA shortcut and write javac File_Name and press Enter.

Step-11: Write java Class_Name and press Enter.