Tuesday, November 22, 2016

Java Hello - Java First Program Discussing

Java Hello - Java First Program Discussing

   

   First Program Discussing - Java Hello

class, public, static, void, main, String arg[], system.out.println(). May be these thing confused you, so don’t worry this simple structure of Java program. 
o   Class is a keyword which represent the class, we will learn about class later. 
o   Public static void main (String arg[]){
}
o   This is pre define main method. Whenever you compile the java Program the Java Virtual Machine first check the main method, if no main method will found, then it will generate the error. So, main method is a necessary method, every program of java will start processing from main method.
o   Java is case sensitive
o   Java class name first letter is always Capital I.e. Demo
o   Access modifier: default, public, protected, private
     o   Non-access modifier: final, abstract, strictfp.
When we compile any java program, the JVM compiler convert the Java code into bytecode, that bytecode is read by JRE and produce the output in human understandable format.



        Hello with Eclipse IDE Java First Program

 o   First download the eclipse from Eclipse official website
 o   After download Extract the ZIP folder, then double click on eclipse Setup
 o   Then its ask for Workspace (workspace is a place where your all project will be saved permanently) so choose the path as you want or leave it as default path.
 o   After eclipse load it show you following output

Java Hello Program with Eclipse IDE

                                                    file menu Java Hello

 o   Close the welcome page go to file menu click on New > Java Project see image below
menu click on New  Java Project
  o   Then a new window open write project name and fit finish button

write project name 
 o   As I give project name “Demo”, now in eclipse your new created project will be shown under Package Explorer tab, expand the demo > right click on src> click on classsee image below

 project name “Demo”

A new window will be opened then write package name (optional) >Class name> fit the Finish button


fit the Finish button


Hello java output

   o   Now output looks like this

hello Demo java
     
    o   Now I’m going just print hello let see an example
hello java

Now to run this program right click on Hello.java> click on Run> click on Java Application



hello java run
   o   Output will be display on Console Tab see image below:
hello.java1

  o   Now hope it’s clear to you about eclipse environment. Same thing you can do with NetBeans IDE; I’m not going to create example with NetBeans IDE; As if you want to work with Integrated Development Environment (IDE) then I’m suggesting you to use Eclipse rather than NetBeans because Eclipse is more light weight then NetBeans and its performance is more accurate.

No comments:

Post a Comment