Sunday, 20 May 2012

Start programming in Java


Java is a desired skill for programmers. It is used for various applications, mobile phones, devices etc. I would like to begin with its introduction.
  •  Java is a programming language originally developed by James Gosling .
  •  It was released in 1995 
  •  The language derives its syntax from C and C++ .
Now, we will proceed further to run simple java program for beginners. For this, there are some prerequisites:

Softwares/Tools

  • Java( JDK 1.6 )
  • Text editor(notepad, notepad++ etc)

Steps

I am assuming that you installed java under C:\Program Files. Now follow these steps:
  •    Press the WINDOWS button on keyboard 
                    -> Run 
                    -> cmd

             Figure 1: Steps to reach java bin directory.


Java -  techterabyte.com
Java bin directory Location
  •  Create a Notepad file and save it as amtdwprogram.java. Always remember that the filename should have same name as the public class name in that file. This conveys  JVM (Java Virtual Machine) about the correct entry point.  Figure 2: our first program in java
Java -  techterabyte.com
amtdwprogram.java

 Here,

      class: new class is being defined.

       
      { }: curly braces in Java is identical to the way they are used in C, C++ etc
      
       public: access specifier
      
       static: allows main( ) to be called without having to instantiate a particular instance. 
      
       main: is the method called when a Java application begins.
      
       String arg[]: declares a parameter named arg, which is an array of instances of the class
       String.the array args[] receives any command-line arguments.
      
       System: it is a predefined class that provides access to the system
       
       out: it is the output stream that is connected to the console.
       
       println: displays the string which is passed to it.

    
     Note: All statements in Java end with a semicolon.

  •      Compiling the program (follow the full path->java->jdk->bin->): 
               C:\Program Files\Java\jdk1.6.0_06\bin>javac amtdwprogram.java 
               C:\Program Files\Java\jdk1.6.0_06\bin>java amtdwprogram

  •       Figure 3: Running the program:

Java -  techterabyte.com
OUTPUT
      
                  



     This way you can run your first program in java.



__________________________________________________________________________
Please comment and forward to others if you like this.
Other posts with video tutorial yet to come.....
"I am sure that blogs really help people around the world.
Let us follow this simple thinking of sharing knowledge . . ."






     

No comments:

Post a Comment