Saturday, 9 November 2013

How To Make Your Computer Speak Whatever You Say

Hi Friends while I was browsing I found this funny trick in which you can make your computer speak whatever you say.
make+computer+speak

STEPS TO MAKE YOUR COMPUTER SPEAK:

1.Open your notepad.
2.Copy the below code and paste it in your notepad.

Dim message, sapi
message=InputBox("What do you want me to say?","Speak to Me")
Set sapi=CreateObject("sapi.spvoice")
sapi.Speak message

3.Now save the notepad file with the name speak.vbs on your desktop.
4.Double Click on speak.vbs and type in the box whatever you want your computer to speak to you.........

5.Enjoy the funny trick..Keep visiting.

Saturday, 2 November 2013

Why we can’t store AC in Batteries instead of DC.or Can we store AC in batteries instead of DC?

We cannot store AC in batteries because AC changes their polarity upto 50 (When frequency = 50 Hz) or 60 (When frequency = 60 Hz) times in a second. Therefore the battery terminals keep changing Positive (+ve) becomes Negative (-Ve) and vice versa, but the battery cannot change their terminals with the same speed so that’s why we can’t store AC| in Batteries.
Also when we connect a battery with AC Supply, then It will charge during positive half cycle and discharge during negative half cycle because the Positive (+ve) half cycle cancel the negative (-Ve) half cycle, so the average voltage or current in a complete cycle is Zero. So there is no chance to store AC in the Batteries.
Also note that Average Voltage x Average Current ≠ Average Power.














Monday, 21 October 2013

How to Transfer Balance from BSNL, Aircel, Airtel, Vodafone, Idea, Tata Docomo

Hello Everyone,
Today while checking the most searched keywords on Google I found an interesting thing that Most of the Users in India don’t know How to transfer their Mobile Balance to their friends or relatives.
So I decided to Make a post on the simple thing.

transfer-your-mobile-talktime

Now I'm going to give you a trick on how to transfer your Mobile balance from your mobile phone to another phone. Using these tricks you will be able to transfer balance for all mobile operators.

Aircel Mobile Balance Transfer Tricks


All Aircel users can transfer their mobile balance up to Rs.100

Use this code *122*666# to transfer you Aircel balance

Airtel Mobile Balance Transfer Tricks


First of all use the below format
1. SMS GIFT amount friend mobile number to 141 [eg: GIFT 50 9908080323]
Next 
2. You will receive a message saying you have that your amount has been transferred to 9876XXXXXX 
Minimum Balance to transfer is Rs.1/-  
Terms and Conditions apply for transferring balance. This trick works only in some states please try this trick with low balance first and go for bigger amount.

Or

Dial: *141# and follow the simple instructions like press the number of share talk time
Transfer Limit: 5 Rupees to 50 Rupees
Note: Sender should have 17 Rupees as their minimum balance to use this facility of  to transfer balance from aortal prepaid to aortal prepaid mobile sim card.


Idea Mobile Balance Transfer Tricks

All you have to do is Simply Follow the below Steps: 
This is an old tricks but still works for some states

Dial: *567*<Receiver’s Number>*<Amount>#
Transfer Limit: 10 Rupees to 50 Rupees
Service Charge: 2 Rupees per transaction
Note: Sender can transfer just one time in a day only.

Or 

This is the latest code to transfer balance .
Dial  *151*1234* Friend Mobile Number * amount # from your Mobile

You can transfer Rs 5 , Rs 10 , Rs 20 using the above code 

BSNL Mobile Balance Transfer Tricks

Just Follow the steps below: 
1. SMS GIFT friend Bsnl number amount  to 53733 or 53738 
[eg: GIFT 949XXXXXXX 50 ]

Tata Docomo Mobile Balance Transfer Tricks

1. SMS BT Mobile Number Amount” and send it to 54321 [eg: BT 72078XXXXX 50] 
2. To reverse the Amount a Member needs to type “ RBT Transaction ID” and send it to54321 
Charges  Rs.1 and for reversal will be Toll Free. 
Terms and Conditions: 
The sender’s account balance for “Balance Transfer” has to be Transfer Amount + Rs.1 at the time of transfer. If balance is not sufficient the transfer will be declined. However, the SMS will be charged. 
In case of Reversals the amount reversed will be dependent on the balance available with the recipient. 
The system will recognize “BT” or “bt” or “Bt

Vodafone Mobile Balance Transfer Tricks

Dial: *131*<Amount>*<Receiver Number># (E.g. *131*30*9820098200#)
Transfer Limit: 5 Rupees to 30 Rupees only
Service Charge: 2 Rupees (5 Rupees to 9 Rupees transfer); 3 Rupees (10 Rupees to 19 Rupees transfer); 4 Rupees (20 Rupees to 30 Rupees)
Note: Sender can transfer only a time in a day and Receiver can receive balance up to 3 times in a day.  Also the processing charge differs with every State so you can ask for transfer charge to your vodafone customer care.

TOP 4 FUNNY GOOGLE TRICK

This summary is not available. Please click here to view the post.

Friday, 2 August 2013



Service Provider

Code

Aircel, Dishnet Wireless

D

Airtel

A

BSNL

B

BPL Mobile/Loop Telecom

L

Datacom Solutions

C

HFCL Infotel

H

Idea Cellular

I

MTNL

M

Reliance Communications

R

Reliance Telecom

E

S tel

S

Shyam Telecom

Y

Spice Telecom

P

Swan Telecom

W

Tata Teleservices

T

Unitech

U

Vodafone





Service Circle

Code

Andhra Pradesh

A

Assam

S

Bihar

B

Delhi

D

Gujarat

G

Haryana

H

Himachal Pradesh

I

Jammu & Kashmir

J

Karnataka

X

Kerala

L

Kolkata

K

Madhya Pradesh

Y

Maharashtra

Z

Mumbai

M

North East

N

Orissa

O

Punjab

P

Rajasthan

R

Tamil Nadu

T

UP-East

E

UP-West

W

West Bengal


Monday, 29 July 2013

Check your own Number


Air tel        = *121*9#

Air cel       = *122*131#

Docomo    = *580#

Uninor       = *555#

Reliance    = *1#

Idea          = *1#

Virgin        = *1#

Vodafone   =    *111*2#

MTS         = Send sms <NUM> to 51230

Wednesday, 26 June 2013

IGNOU MCA EBOOKS

IGNOU MCA students can download the course material in the form of ebooks. Here I am presenting the study material in the form of pdf books. It includes all the semester subjects. The material is simply the ebook version of the material given to the IGNOU students when enrolling for the MCA course.

Below books are meant only for IGNOU MCA registered students. If you are not a IGNOU student, then please don't download ebooks from here.


  1. MCS-011 Problem Solving and Programming
  2. MCS-012 Computer Organization and Assembly language Programming
  3. MCS-013 Discrete Mathematics
  4. MCS-014 Systems Analysis and Design
  5. MCS-015 Communication Skills
  6. MCSL-016 Internet Concepts and Web Design
  7. MCSL-017 C and Assembly Language Programming Lab
  8. MCS-021 Data and File Structures
  9. MCS-022 Operating System Concepts and Networking Management
  10. MCS-023 Introduction to Database Management Systems
  11. MCS-024 Object Oriented Technologies and Java Programming
  12. MCSL-025 Lab (based on MCS-021, 022, 023 & 024)
  13. MCS-031 Design and Analysis of Algorithms
  14. MCS-032 Object Oriented Analysis and Design
  15. MCS-033 Advanced Discrete Mathematics
  16. MCS-034 Software Engineering
  17. MCS-035 Accountancy and Financial Management
  18. MCSL-036 Lab(based on MCS-032, 034 and 035)
  19. MCS-041 Operating Systems
  20. MCS-042 Data Communication and Computer Networks
  21. MCS-043 Advanced Database Management Systems
  22. MCS-044 Mini Project
  23. MCSL-045 Lab(UNIX & Oracle)
  24. MCS-051 Advanced Internet Technologies
  25. MCS-052 Principles of Management and Information Sytems
  26. MCS-053 Computer Graphics and Multimedia
  27. MCSL-054 Lab( based on MCS-051 & 053)
  28. MCSE-003 Artificial Intelligence and Knowledge Management
  29. MCSE-004 Numerical and Statistical Computing
  30. MCSE-011 Parallel Computing

Live Like Today is Your Last Day!

This post is all about my personal thoughts. But do consider reading this post because it teaches so many things related to life which we generally use to ignore. Have time? Then continue reading.

Are we really enjoying life? Let us see a small glimpse what is happening in our life. At first in school days, we are dying to finish our high school and start college. And then we are dying to finish college and start working. Then we are dying to marriage and have children.Then we are dying to retire. We think at this age we will enjoy life. But what is the guarantee that we will be alive up to this stage? And then when we are dying, suddenly we may realize 'I forgot to live'. Please don't let this happen to you. Enjoy each and every moment in your life.

Actually we are making thorough preparations for rainy season such that we are forgetting to enjoy today's sun shine.

Why we give so much importance to make money? To make money we lose our health and then to restore our health we lose our money. We live as if we are never going to die, and we die as if we never lived! So my dear friends appreciate your current situation and enjoy each day!

Here is a little sharayi taken from the movie "Zindagi Na Milegi Dobara" written by Javed Akhtar. If you know Hindi you will really enjoy the meaning of it.


Dilon mein tum apni Betaabiyan leke chal rahe ho
Toh zinda ho tum
Nazar mein khwabon ki Bijliyan leke chal rahe ho
Toh zinda ho tum
Hawa ke jhokon ke jaise Aazad rehno sikho
Tum ek dariya ke jaise Lehron mein behna sikho
Har ek lamhe se tum milo Khole apni bhaayein
Har ek pal ek naya samha Dekhen yeh nigahaein
Jo apni aankhon mein Hairaniyan leke chal rahe ho
Toh zinda ho tum
Dilon mein tum apni Betaabiyan leke chal rahe ho
Toh zinda ho tum

Dance like nobody is watching.
Sing like nobody is listening.
Love like you've never been hurt.
Work like you don't need the money.
Live like it's heaven on earth.

Let me know your thoughts regarding your life by commenting below!  

Introduction to Java

Welcome to our first session of Java Tutorial. This is for those people who are absolutely new to programming. Hope you will like our first session.


Before starting our session let us introduce myself. Of course you know pretty well who I am. But still people who are new to my site can visit About Me page for further details regarding me. I am too interested to know about who you are! So let me know your details by dropping a comment below.

I am a strong lover of C language. But I like Java too. I am programming in Java for the past 6 years. In this mean time I got so many situations where I felt that Java is the perfect language to solve a particular problem. I also experienced some situations where Java was little helpful and I have to shift to my lover C :).

Since this is a online tutorial I just want to confirm whether you are reading each and every word correctly or not. I mean whether you are in hurry or not. Generally people who are addicted to learn via listening will find this tutorial a little bit confusing. But trust me I will make it easy and fun.

This is for just for test. Read the quotation given below only once and identify how many times the letter F is repeated. Remember you have to count the F's by reading the quotation only once.


"FINISHED FILES ARE RESULT OF YEARS OF SCIENTIFIC STUDY COMBINED WITH THE EXPERIENCE OF MANY YEARS"

Now let me know your answer. Anybody got the count 6? I think many of you have ignored the F present in OF. So what is your count?

The above test is just an alert for you to observe each and every word written by me. Actually I may have directly jumped to starting lesson like features of Java, data types and so on. But then there is no difference between books and me. I just want to make sure that you should enjoy programming and don't by heart each and every statement.

Always remember that Programming is nothing but understanding yourself! The more and more you are programming the more and more you are understanding yourself.

Many people try to introduce Java by blaming C and C++. I don't know why this trend is followed by all. For me C is created for separate purpose, C++ is created to solve different problems and Java is created to solve some other critical problems. Actually none of them are interrelated. You can compare the syntax's but you cannot compare and say that Java is a great programming language and C is useless. Still there are plenty of openings in C are there and Java cannot be used in replacement to C.

OK. That's enough of comparing! I have to say lot of things but unable to express all my thoughts via this post because I am new to typing. Please ignore my grammar mistakes but try to highlight my programming mistakes in a program :).

So in order to program in Java basically we need Java software. If it already exists in your system then no problem! But if it is not present then I recommend you to have it via your friends or you can download it free of cost from the official site link Java Download. At the time of writing this post in the official site JDK 7 update 2 is available. By clicking the link a page will be opened and you will find JAVA SE Downloads. Select the first icon. Now you have to accept the license agreement in order to download Java.

Generally we are having two types of systems (OS). 32 bit OS or 64 bit OS. Maximum all the operating systems we are using comes under 32 bit category only. So I recommend you to download 32 bit version Java software. If you are sure that your Operating System is 64 bit OS then go for 64 bit version Java software.

In order to download 32 Bit OS compatible software just click on the link that says Windows x86. Don't worry you are downloading the right version only. 32 bit is not referred as x32 :). It is widely recognized as x86 due to Intel 8086 processor version naming convention.

If you are using Linux operating system then go for either Linus x86 or Linux x64 depending upon your OS.

For Windows OS the Java file size is around 84 MB and it is named as jdk-7u2-windows-i586.exe. If the net connection is slow it will take time. Hence I had provided the download link in the starting session itself so that from the second session onwards you don't need to mess up with all these things. Hope the downloading procedure is clear to you now.

I have already installed JAVA SE 6 or 5 present in my system. Shall I have to download Java SE 7?
If you have already installed or the old version of Java is already there in your system then also I recommend you to download the newest version of Java SE 7 because I am going to cover some features which will not work in older Java versions. Of course I will inform about those features when the time comes.

In order to type your program you need some interface also. The advanced interfaces generally referred as IDE's (Integrated Development Environment). The world famous IDE's for Java are Eclipse and NetBeans. But at this stage I don't recommend you to download Eclipse or NetBeans because as a beginner you will be confused regarding how to use them. And these are actually not necessary also.

You can go for simple file editors like EditPlus or Notepad++ . Even these editors are not necessary at all.

The best way to start programming in Java is via Notepad present in Windows XP or Windows 7 or via vi editor present in Linux. These two editors are built in and you don't need to download any thing at all :). Pretty cool!

If Eclipse, NetBeans, Editplus or Notepad++ are not necessary why are you providing this info?
In order to answer this question I have to mention one incident that I personally experienced. One of my friend attended training session on Java in a famous institute and the institute told that they offer world class training on Java via Eclipse software. They said industry uses Eclipse and not notepad. If you are programming in notepad then it means you don't know any thing at all. They said as a beginner you should go for Eclipse so that you can enter into software industry quickly.

The answer given by that training institute is just a trash. As a beginner if you go for Eclipse you may get comfort in typing but actually the core of language is get hidden and you may not answer even a simple question on how to execute a Java program. So my dear friends believe me you don't need to download any thing except JAVA SE 7.

At present Java software is mainly available in three flavors. They are Java SE (Java Platform Standard Edition), Java EE (Java Platform Enterprise Edition) and Java ME (Java Platform Micro Edition). Previously they used to be known as J2SE, J2EE and J2ME. Java SE is mainly used to develop desktop applications and it is the core of Java. We are going to deal with this only and the link is already provided to download above. Java EE is used to develop server applications and hence in order to learn this you need strong foundation in Java SE. Java ME is mainly used in embedded devices like mobile phones. All the three technologies are widely popular. Of course Java ME is somewhat loosing it popularity because Android (Google product) applications are growing in the market. But still having strong foundation in Java SE will help you to learn Java ME and Android easily.

Java is having one more flavor known as JavaFX. This is still not popular. But we cannot predict its future right now.

Our discussion is only on Java SE i.e. on Standard Edition. Some used to call it as Core Java also. It consists JRE (Java Runtime Environment), JDK(Java Development Kit), JVM (Java Virtual Machine) and many more tools. Don't worry we will see all these one by one. Just be familiar with the names!


Java SE Version History, Code Names and Release dates:

















Java VersionCode NameRelease Date
JDK 1.0OakJanuary 1996
J2SE 1.2PlaygroundDecember1998
J2SE 1.3KestrelMay 2000
J2SE 1.4MerlinFebruary 2002
J2SE 5.0TigerSeptember 2004
Java SE 6.0MustangDecember 2006
Java SE 7.0DolphinJuly 2011

The above table shows the major releases of Java as well as their code names. Please do remember the code names because in some technical interviews they just used to ask you what are the extra features available in Tiger as compared to Merlin? Tiger is just a nick name of J2SE 5.0 then only you can understand what actually the question means. One of my friend just answered that he doesn't know Tiger language :).

If Java is successfully installed on your system then open command prompt (Just press Window Key+R Key simultaneously and in the dialog box type cmd) and type the following command Java -version

D:\N>java -version
java version "1.7.0"
Java(TM) SE Runtime Environment (build 1.7.0-b147)
Java HotSpot(TM) Client VM (build 21.0-b17, mixed mode, sharing)

If you get the above output then it means Java SE 7 was successfully installed on your System.

At this moment the time is sharp 1 AM and I am going to schedule this post for morning 9 AM. Sorry friends I was unable to start Hello World program because there are so many things I want to cover before our starting program. Hope you enjoyed the session.

Let me know your valuable views and suggestions by replying via comments!  

Java Tutorial For Beginners

Hi friend! Are you interested to learn Java programming online? Then this is the perfect place to learn it easily and quickly. Those who are not related to programming please kindly skip this post.

Actually I planned to introduce a step by step tutorial on Java at the beginning of this year itself but unfortunately the idea got postponed due to my freelancing projects as well as due to personal problems :cry: and finally I got time to introduce this tutorial at the end of the year :).

Before going to start the tutorial let us discuss who should learn Java? If you want to learn Java programming I strongly recommend you to have programming skills in C language. And it may be much better if you know a bit of C++ also. But don't think that if you don't know C you cannot learn Java!. It's possible to jump directly to Java but you cannot enjoy the way a C programmer is going to catch the concept. Hope you understand my point.

And finally regarding this tutorial this is purely for beginners. I am planning to write at least thirty articles on Java. If this is not sufficient I will expand it up to 45. People who are well versed with Java can also go through this tutorial because I am not going to cover the concept in a way you are going to find in books. Everybody will have a different view on the language. So my view may be a bit different and I hope you may like this!

I was much inspired by a quotation given by creator of perl language Larry Wall. He says:

"A language is not worth knowing unless it teaches you to think differently."

So I will always try to present the concept by keeping the above quote in mind. Each day a new post will be posted at morning 9 AM. I will try to be online at this time so that if you have any queries regarding the concept you can clarify them instantly. Anyway you can also post your comments at a later time and I will provide the solution with in 24 hours.

All the links will be available in this post so that you can refer to the tutorial from one place easily. So my dear friend try to attend for tomorrow session online at sharp 9 AM :).

One more thing! while posting comments do address me simply Naresh or Naresh Bharat. No need to call as Sir. I actually feel a lot inconvenient when somebody refer me as sir. Because I believe that a teacher is a life long student and a student is a life long learner. I too expect to receive some thing new from you. Hope you don't disappoint me!

This Java session is dedicated to my teacher Prasanna with out whom I can simply say that I may not be related with computer field. Prasanna used to teach C language to me at my degree level. Inspired by Prasanna I learned Java on my own.

Tutorial 1: Introduction to Java

Tutorial 2: History of Java

Tutorial 3: Features Of Java

Tutorial 4: Java Basics

Tutorial 5: First Java Program Execution

Tutorial 6: Java Naming Conventions

Tutorial 7: Keywords in Java

Tutorial 8: Basic Data Types in Java

Tutorial 9: Operators in Java

Tutorial 10: Control Flow Statements in Java

Due to some personal problems I was unable to present the tutorial daily. Inconvenience caused is deeply regretted. 

Features Of Java

Hai friend! Welcome to our tutorial. Today we are going to discuss the features of Java and try to find why Java became popular.

Let us start with a real world scenario. Suppose a company decided to hire a candidate for an opening. It has offices at different locations in the world. Also imagine that Naresh is going to apply for this position. One more point here is even the company has worldwide locations I am interested to apply for Bangalore India only. I mean other than this location I am not interested to work any where. I am location dependent. Is the company going to prefer me? Not at all.

Generally companies going to prefer the candidates who are able to relocate anywhere in the universe :). The people who are willing to work at any location can be termed as location independent. Means they does not depend on location.

Like the same way imagine if you have written a program on one system say Windows XP operating system. If the same program is not going to work on other operating system like Linux OS we can say that the program is system dependent or platform dependent. Less people prefer these programs because in future there may be a chance of changing the system and the program simply becomes useless.

Java is Platform Independent. You already know what this means!

In real world there is no data and no logic. Imagine that every one is an object. Let us say that Naresh is also an object. I have some attributes like height, weight and color. I also exhibit functionalities like walking, talking, swimming and blogging :) etc.

If any problem is going to be solved by this type of thinking you can say that it is an object oriented program. Of course there are a lot of features to be supported by a program in order to term it as an object oriented programming example.

Java supports Object Oriented Programming. I will try to cover these features later.

Let us consider one more feature of Java. Java is secure.

Suppose if you want to meet a top minister to discuss some personal things.

Generally VIP's enjoy high security. So in order to meet them you have to first approach a high command person who actually used to transfer the message to that person. That means between you and the VIP there exists another person who used to interact with VIP and you. But why is this mediator? You know pretty well to protect the minister.

Like the same way Java provides one type of sandbox effect where you are going to interact with the system via JVM. That means you are not going to directly access the system. It is via JVM sandbox. This way Java became secured.

Let us discuss one more feature. Suppose I told you to add two numbers. Then you should get those two values so that addition can be performed on those numbers. But I have given values as n and b. Can you add two letters? No. So immediately you should say that please give a number and not letter. This time I given a number 9. Is it sufficient to perform addition on single number? No. Again you will say that please give me two numbers. This is the way a computer should be programmed. Never expect user will input as per your thinking. We cannot predict a user mind. Your program should handle all type of inputs and should provide appropriate action based upon the particular mistake. These type of features makes a language error free. Also referred as robust.

Java is robust.

Java supports many more features like multithreading, automatic memory management, distributed programming and so on.

I will expand this post later. 

History Of Java

Hi friends Good Morning! Welcome to our second session. Today I am going to discuss history of Java instead of going for Java program directly. Because I think you should know a little bit history before starting our first Java program.


In general James Gosling is referred as father of Java programming language. Let us have a small flash back.

Initially in 1990's Patrick Naughton is working on Sun's project named Stealth Project. Later this Stealth Project was renamed to Green Project when James Gosling and Mike Sheridan joined this project. Later Bill Joy also joined this. You can say that James Gosling is the team leader for this project. Actually these people initial goal is to built embedded software for consumer electronic goods like set top boxes and cable TV. Later they shifted their focus on world wide web, and this became the turning point.

The team called this developed language as Oak (There are stories on internet that Oak is the tree the team used to see via window). But since the name is already registered by some company they want to change to different one. Then the team came up with alternate names like Java, DNA, WebRunner and Silk. From these names at last Java was chosen.(It means coffee. The team used to drink a lot of coffee and fine quality coffee is imported from Java island, Indonesia. That's why the language name kept to Java!). US people general slang for coffee is Java.

By this way first version of Java came in the year 1995 by Sun Microsystems. The name Sun stands for Stanford University Network. Even though Java was created by James Gosling, the company Sun Microsystems was founded by Vinod Khosla (an Indian). This is really a great feeling for every Indian.

This is not the only case. For every revolutionary product or idea behind the scenes there will be an Indian. Yes I have so many examples to prove this point. When the time comes I will present them.

But later on Oracle purchased Sun Microsystems and Java became the product of Oracle Corporation. This may be a sad news, but no problem! Java future is safe under Oracle.

So what about James Gosling? Where is he now?
Don't worry! He is alive :). James Gosling worked with Oracle for some time and then he joined Google Company. But sadly he doesn't worked in Google also for long time and later he joined Liquid Robotics.

I provided all these updates time to time to my regular visitors the moment it happened. At present he is associated with Liquid Robotics. Are you interested to visit James Gosling blog then it is at www.nighthacks.com. I am a regular visitor of his blog!

Sorry for a short post. Scheduling this post for tomorrow morning 9 AM. Hope you will enjoy this!

Liked today's session? If not then I want to share one more thing. James Gosling had two daughters, named Kate and Kelsey :). 

First Java Program Execution

Before going to run our first Java program we need some settings on our computer to execute our program. Let us see them.


In Windows XP or 7 we need path setting in onrder to execute our Java program. I all ready provided the download link to download Java software.

If you have download JDK1.7 update 2 then in your system you get one folder like this. I am assuming that Java is installed in C drive.

"C:\Program Files\Java\jdk1.7.0_02\bin" This folder contains Java compiler and Java interpretor which are necessary to compile and run our program. Hence these tools are necessary to be in our Windows PATH so that we can use them. To do this we need to include the above directory in our Windows Path so that OS can recognize our commands.

Just copy the above path with out quotes and include it in the path by following the steps below.

Right Click on My Computer Icon present on the desktop and choose properties. Click on Advanced tab and in this tab click on Environment Variables. You will find two types of panes User Varaibles and System Variables. Under System variables search for the variable named PATH. Now click on Edit. If it is not there click on New Button to create it.

If the PATH already exists then the current path is shown in varaiable value. Don't delete the existing value. Just add our JDK path to the existing path. To do this just add ; at the end of current path and paste the above path. Just press OK. Be careful will editing these settings. It will look like this.

Variable Name: Path
Variable value: .......; C:\Program Files\Java\jdk1.7.0_02\bin

How to verify PATH setting is successful or not?
Just open command prompt and type javac and press enter. If it says javac is not recognized as an internal or external command then it means there is something wrong with your path settings.

If the PATH setting is correct you will get its usage syntax and a list of options supported by the command.

This is all regarding the PATH setting.

Since we are going to execute a lot of programs let us make one personal directory where all our Java related programs can be stored. Assume that in my system I am going to store all my programs under D:\Naresh>.

Goto start and open Run or just press the shortcut Window Key + R. Type cmd and you will taken to command prompt. By default it points to current directory. Just shift to D drive by typing D: and create one directory named Naresh (give any name of your choice) by the command md naresh then move to my directory Naresh by change directory command cd Naresh. Now the path appears like above D:\Naresh>.

Now let us start our first Java program. Create a file named First.java where we are going to write our source code. Here is the shortest way to do this!

D:\>Naresh>notepad First.java

The above command will open a Notpad window and it will ask Whether you want to create a file named First.java . Just press yes. If the file already exists it will just open the file with out displaying any dailog box. Now type the following code in this file.


/*  

First Java program by Naresh Bharat.
Visit www.nareshbharat.com for free Java Classes Online.

*/

import java.lang.*;
class First
{

public static void main(String args[])
{
System.out.println("Hello World!");
}

}

After typing the code just save the program by pressing Control and S key simultaneously. Otherwise Click on Close button and it will ask whether you want to save the changes. Press yes and you are done!

To compile the Java program we need java compiler. This can be done with the help of javac command. Just type the following command at prompt.

D:\Naresh>javac First.java

If you get the prompt immediately after giving the above command like below

D:\Naresh>

This means you successfully compiled your Java program. If there is any error then error will be displayed. If it contains any error again open Notepad window edit your program and come back to the command prompt and once again try to compile the program. Repeat this procedure until your program is error free.

If every thinng is OK, you will get First.class file in your current directory. This is the byte code. Just for confirmation type dir command and verify the files list. You will find that java compiler has created one .class file related to your program

Now to run our Java program we need Java Interpretor. For this use the following command.

D:\Naresh>java First
Hello World!


Just type the class name i.e. First. Don't give .java or .class extension here. The command java just takes class name with out extension.

If you get the above result that means you are successful in executing our first program. Every Java program execution is like this only.


Actually I just exectued the program with out explaining any thing about what really the purpose of every line written. Let us discuss in more detail.

/* */ This is know as comment section. Every thing written inside /* and */ is just for our understanding. Java compiler just ignores all the content present inside comments. You can assume it just like you write the date in your notebook so that it can be referred later easily. You write date in your notebook just for your sake. The content in your notebook is not related to date at all. Like the same way comments are just for our understanding. Do remember that comments can be defined any where in a Java program.

If the comment contains a single line Java provided one more style as a shortcut. Just type // and write your comment. Any thing written after // will be ignored by compiler. But your comment should not conatin more than one line.

Java even provided one more comment style known as documentation comment. It starts with /** and ends with */. I will discuss this later when the need occurs.


The import statement is used to import the packages in our program. Here I am include java.lang package into my program. By default even if you don't write this, the packace is imported automatically. Just for knowledge sake I mentioned it.

Every language will have set of rules to be followed while programming. Java states that every thing should be written inside a class. And the calss syntax is very simple!

class
{

}

Note that here class is a keyword used to tell the compiler that class declaration is to be defined. The content in the class is to be included with in { }.

Every standalone Java program execution starts from main method. Unfortunately main method syntax in Java is somehow lengthy as compared with the syntax of C.

I will try to explain what is the purpose of every word. Don't worry even though if you are not getting into this concept. As a starter it is difficult to understand perfectly the meaning of every keyword. Gradually when the specific concept comes you will get better idea.

public keyword is used to access the main method by outside world.

static keyword is used to access main method directly with out creating object. This is enough just for now. Later you will come to know what is meant by object creation and all the things related to it.

void is used to indicate that main method is not going to return any value. If any method does not return any value then it return type should be mentioned as void. This will be more clearer to you when methods are covered. If you know C then you know this already.

main is the method name. According to Java naming convention and specifications the main method should be named only to main. That's why it is defined like that. () indicates that it is a method.

If you want to pass any values to main method at command prompt then the main method should be capable of reading and strong them (the values or data given by user) so that it can be processed. For this purpose String args[] is mentioned. String is the class name and args is the variable of type String and [] indicates that it is going to store an array of String values. Again please don't worry if you are not getting this. This will be more clearer to you when we discuss array declaration syntax.

The main method code should be mentioned within the braces only. Thats why {} are used.

In order to display some thing on screen we can use println method. But printing is not that simple as compared to C. It is called via System class. out is an object. The System class exists in java.lang package. It is imported by default if you don't import it. Please remember the syntax for now, because you are new. All the details will become more clearer to you when we cover more concepts related to them.

In order to understand this Hello World! program we need to know lot of concepts. I had just given some brief idea to make aware of the program. Of course I know that this is not enough to you to understand perfectly.

Those who already know Java may find this session not much useful. Sorry but I had started this tutorial keeping a beginner in mind who just knows that Java is just a programming language and nothing else!

Hope the session is useful to you. Don't worry nothing is going to happen to you if you don't understand it. If possible read this post once again. Also follow the tutorial order accordingly. Don't go for next tutorial before covering the previous tutorial.

Let me know your feedback via comments!  

Java Basics

Hi friend Good morning! Welcome to our new session. But don't think features of Java post is over. I will update it time to time.


Today we are going know things that are needed to understand our first Java program. A person who already know Java may not need this post.

Generally you are going to write a program to instruct computer to perform your desired task. The program written by you simply contains code written in English. If a language code is written in plain english, easily understandable format you can say that it is an example for high level language. Java is a high level language!

Also remember that the code written by you is known as source code. Every file in computer system contains some extension so that it can be easily identified by OS. For instance the image files in your computer System will have .jpg extension and the audio files generally have .mp3 extension. Like the same way a C program will have .c extension and a Java program contains .java extension.

We are going to write our code in this .java extension file. But here is a catch. If you are going to write your code in english words (of course you have to follow language rules and syntaxes) then how computer is going to understand your commands because it doesn't know other than binary language or machine language.
So you need a mediator who can convert your code in machine understandable format.

Translators are needed to convert your code from one format (high level) to another (machine format). There are two types of translators. They are Compilers and Interpretors. Compiler is going to translate whole code into machine format at once. Whereas interpretor is going to convert it line by line.

In Java compiler is used to translate our code into Byte code. Byte code in Java is having the extension .class. But byte code cannot be executed by our system directly. For this Java provided JVM (Java Virtual Machine). JVM is going to execute the byte code directly and we will get our results. That means JVM is also one type of translator. Of course it has many reponsibilities. But remember JVM executes code line by line, that means it is an interpretor.

We already discussed that Java is platform independent. Here in this post we will see how this is happening. We came to know that after compiling we are getting one file known as .class file. This class file is machine independent. That means if you are going to compile a Java program on Windows XP, you will get one .class file. The same .class file you can copy and place on another system like LINUX. You don't need to chance any thing. The JVM present on linux system can execute this .class file and it will give results on the fly.

Here is a tricky question asked in interviews.

Is JVM platform independent?

Don't get confused. I am asking about JVM and not Java. Actually JVM is machine dependent. For every operating system Oracle provided separate JVM so that it can easily interact with OS. That's why in my first post I told you to download one software which is specific to your need like JDK1.7x86.exe. For linux you have to download separate file. This JVM is provided inside this software. So Oracle provided separate software depending upon your OS. This clearly shows that JVM is platform dependent.


Hope the idea regarding JVM is somewhat clear to you now. Let me know if you are still confusing.

I will deal with program in the next post. 

Java Naming Conventions

Hai friend Good morning! Welcome to Java session. Today we are going to discuss some naming conventions to be followed in Java.


Class names in Java should start with capital letter. If the class name contains two words, the first letter of both the words should be capital. Also method names should start with small letter and the sebsequent word first letter should be capital. Every statement in Java should end with semicolon.

Java language has certain keywords. Keywords are certain words which are having special meaning to Java and hence these keywords should not be used for other purpose other than for what they are meant to.

In Java if you want to store any value then you should declare one variable to hold the value. Variable is nothing but named memory location where a value can be stored. Also remember that variable value changes during program execution. That's why it is termed is variable. Some times it is also referred as Identifier. There are some rules when you are going to name variables.


Variable naming conventions in Java:

  • Keywords are not allowed to name a variable.
  • Variable name can contain any number of characters. But it is recommended not to go for long names because it is difficult to remember it at a later stage.
  • Variable name should not contain any special characters except $ and _. I mean $ and _ are the only special characters that are allowed to name a variable.
  • Variable name should always start with an alphabet or special character $ or _. It should not start with a number.Of course the second character onwards numbers are allowed. Even though first character can be $ or _ it is not recommendd to use them.
  • Java is case sensitive. That means upper (capital) and lower (small) case letters are always treated as different.

List of Keywords in Java

Hi welcome to the Java session. Today we are going to see the list of keywords available in Java.

We already know that keywords are reserved words which are having special meaning to the Java language. Hence we are not allowed to use keywords to name a variable, method or class name etc. A total of 50 reserved words are there in Java.

The list of keywords are:

  1. abstract
  2. assert (This is added in JDK 1.4)
  3. boolean
  4. break
  5. byte
  6. case
  7. catch
  8. char
  9. class
  10. const (This is not used)
  11. continue
  12. default
  13. do
  14. double
  15. else
  16. enum (This is added in JDK 1.5)
  17. extends
  18. final
  19. finally
  20. float
  21. for
  22. goto (This is not used)
  23. if
  24. implements
  25. import
  26. instanceof
  27. int
  28. interface
  29. long
  30. native
  31. new
  32. package
  33. private
  34. protected
  35. public
  36. return
  37. short
  38. static
  39. strictfp (This is added in JDK 1.2)
  40. super
  41. switch
  42. synchronized
  43. this
  44. throw
  45. throws
  46. transient
  47. try
  48. void
  49. volatile
  50. while

Apart from the above keywords true, false and null might look like keywords, but actually they are not keywords. Still these are not allowed to name a variable.

Do remember that main is not a keyword in Java. That means main can be used for naming a variable. Of course it's a bad programming practice!

All these keywords will be covered in our tutorial. Hope the today session is useful to you. 

Data Types in Java

Hi friend! Today we are going to discuss primitive data types available in Java.


Java basically supports eight primitive data types. Data type is generally going to identify what type of data is going to be stored in the memory location.

Let us see why we need data type? In general we use to represent data either in number format or non number format. The data which is going to be represented may occupy some memory. Small numbers may need less memory and big numbers may need more memory. Like the same way your name is nothing but a collection of characters which need memory based on number of characters present in it.

Hence languages defined data types so that memory can be utilized efficiently and data can be identified by just seeing the data type. In computers every thing is represented in bits. For example if you want to store a number say 9 then in binary language it will be represented as 1001. If the number is large then it occupies more bits.

In java every variable must be declared before using it in the program.

The eight primitive data types are as follows:

  1. byte: This is used to store integer values. In this we can store any number between -128 to +127. It occupies one byte of memory (8 bits). Why the limit is upto 127? Because 127 is the largest number that can be represented in 1 byte memory. Convert it into binary and see how many bits you are having! Do remember that one bit is reserved for sign. If the number is positive then the sign bit value will be zero otherwise one.
  2. short: This is also used to store integer values. But it has longer range as compared to byte. The range is from -32768 to +32767. It occupies 2 bytes of memory.
  3. int: This is also used to store integer values. This can accommodate values larger than short data type. The range is from -2,147,483,648 to +2,147,483,647. Both the numbers are inclusive. It occupies 4 bytes of memory.
  4. long: This is also used to store integers. This can have values which can't fit in int data type. The range includes -9,223,372,036,854,775,808 to +9,223,372,036,854,775,807. It occupies 8 bytes of memory.
  5. float: This data type is used to store real numbers. Numbers which are having fractional part in it. It occupies 4 bytes of memory.
  6. double: This is also used to store real numbers or floating numbers and its range is always greater than float. It occupies 8 bytes of memory.
  7. boolean: This data type can have only two values either true or false. Generally it represents one bit of information.
  8. char: This data type is used to represent a single character. Every key on the keyboard can be considered as a character. It occupies two bytes of memory.
Apart from the above 8 primitive data types Java supports collection of characters as a String data type. Don't confuse it with basic or primitive data types. String is a predefined class in Java.

When we do programs on the above data types then you will get more clear idea on these data types. Hope today's session is useful for beginners.