installation,path setting, HelloWorld program

How to Install Java
Steps to follow: ----
www.java.sun.com-----DownLoads----Click and  Again click in the same place---One POPUp window comes----Click---downlods----rightside-----popular downloads-----java for developers-----click---Javadownload (first tab)-----select accept licence agreement option button---select windowsi586(for 32 bit computer)----select-----then one window comes----jdk-7-window-i586.exe---savefile---then installation starts-----after finishing this ----whereever we want we can copy and paste that donloaded folder----then doubleclick on the folder—next---next-----finish
After the installation it creates one folder structure: ----
                                                      C:\                                
                                                              ProgramFiles
                                                                    Java
                                                                     Bin
                                                                       Lib
                                                                           Examples                                                                     
                                                                              Jre7
Jdk folder consists of subfolders lie bin, lib, jre 7 etc.
After Installation
1. Bin: ---It consists of all the application files which are used to compile, execute, decompile etc.
2. Lib: -- It consists of all the library files which give support for JAVA applications.
3. JRE: ---JAVA runtime environment which gives support when we are executing the program.
4. JRE7:---It provides help to run java applications in  browsers.
5. JAVA Environment Variables: ---- This we use to set the configuration of JAVA to local System Right click on My computer---properties---advanced tab---Environment variables----user variables----new—variable name---path –variable  value -- c:\programfiles\java\jdk1.7.0\bin;
Classpath--- Environment variables-------new— classpath--c:\programfiles\java\jdk1.7.0\bin\tools.jar;.;---ok.
Then goto cmd---run—javac---enter------java---enter

HelloWorld program development 


Java Program Structure:
/**
*document type of comment
*/
Package section
Import section
Class section
{
Declaration of variables, methods, blocks….etc
main method
}

Sections In Java: ---
The Java Platform Api Specification Contains The Complete Listing For All Packages, Interfaces, Classes, Fields, And Methods Supplied By The Java Se Platform. Load The Page In Your Browser And Bookmark It. As A Programmer, It Will Become Your Single Most Important Piece Of Reference Documentation.

1. Package Section: ---
What Is A Package?
A Package Is A Namespace That Organizes A Set Of Related Classes And Interfaces. Packages are Similar To Different Folders On Your Computer.
“A  package consists of classes,interfaces,enums,annotations…etc ”
  package com.first;--à user defined  package
  import java.lang.*;--àpredefined package
  Class Myclass {
 }

 2. Import Section
Is Used to Import the Java Files Into User-Defined Program From Library.
 import Java.io.*;
(Like In C We Use #Include)

3. Class Section
A Class Is The Blueprint From Which Individual Objects Are Created. There May Be Thousands Of Other Bicycles In Existence,. Each Bicycle Was Built From The Same Set Of Blueprints And Therefore Contains The Same Components. In Object-Oriented Terms, We Say That Your Bicycle Is An Instance Of The Class Of Objects Known As Bicycles. 
The Class Consists Of All the Members of A Java Program.We Should Write Every Thing In The Class Only.

Main():---
Is used to write the main method logic in  a program.

Writing the first Java program
 Open any following Editor.
ü  Notepad
ü  Editor
ü  Notepad++
ü  Editplus
ü  Eclipse/myeclipse
ü  Netbeans
ü  Vi(for unix)

/*
*     this is my first program in java
*     helloworld.java
*    date:10/14/2011
*  author : Kiran Kumar
*/
import java.lang.*;
class HelloWorld
 {
public static void main(String [] args)
  {
System.out.println(“hello world!”);
  }
}
Save the above file with HelloWorld.java
To execute the program
D:\core\>javac HelloWold.java
To run
D:\core\>java HelloWold

No comments:

Post a Comment