Saturday, November 2, 2013

#2 Hello Java

Hello,

Here is my first Java tutorial. In this post I am going to introduce you to Java. So get ready to say Hello..! :P

Hello Java:
We (humans) use language as a tool for communication or for conveying our thoughts to other person. In the same way we need a language where both the humans and machines can understand so that we can order/command machines to work for us..! :P This is how the Computer programming languages have entered into the world. Java is one of the most popular programming languages. Here is the process what exactly happens with Java programming.
  • Java has certain standards and specifications. We need to follow them for composing a Java program. Java programs need to be saved with .java extension.
  • We have to compile that human-written/readable .java file. When we compile it, Java will generate machine-written/readable .class file. The data inside the .class files will be in 0’s and 1’s (bytecode). That is the reason we say Java is a machine independent language.  In other words, we can carry that .class file to any other system (irrespective of Operating System) in the world and we can execute it.
  • Once the .java file is compiled or we can say, once we get the .class file, we have to run it to see the expected results. Of course, if you do not follow Java’s specifications you will get an error instead of your expected result.

Let us see how to install Java and in my next post you can see how to perform the above mentioned 3 steps.
Install Java:
In this section I mostly concentrated on WHY/WHAT rather than HOW. For your questions which contains HOW, I have referred you to another sites.
So first you need Java setup file to install it in your system. You can download it from https://java.com/en/download/index.jsp.
Installing Java in a Windows Operating System is just like any other software installation process clicking Next --> Next--> I agree --> Next until you get Finish button..:P
For more info, you can see the complete installation process at http://support.skillsoft.com/customer/javainstructions.htm. To confirm that the Java has installed successfully in your system, you can follow below procedure.

  •       Open the command prompt. You can do so by
Start --> Run. Or Windows+R. Type cmd and hit OK button. You will get a window as shown in the below screen-shot.
(Don’t worry if you find the different path C:\Documents and Settings\Administrator in your command prompt.)

  • .       Type java –version command and hit enter. If the Java has installed successfully, then you should be getting something as shown in the below screen-shot.

(I have installed java 1.5 version, I know I am outdated..:P But you guys can get the latest 1.7version.)

If you see something similar as above, then Congrats..! You have successfully installed java.

Hit Points:
  • James Gosling is the father of Java. (Don’t worry he is still alive. Happy and Healthy. :P)
  • Java programs can be written in a notepad and should be saved with .java extension
  • When we compile .java file, we get .class which contains bytecode.
  • We need to execute that .class file to see the results.
  • In my next post you will learn why/how to set Java classpath and how to compile/execute a Java Program.
I hope you had a happy learning. Any suggestions, feedback, concerns, corrections or questions can be communicated through sanjay.lindlars@gmail.com

Thanks.


0 comments:

Post a Comment