Java Tutorial

From Tutorial
Jump to: navigation, search

Java Tutorial Introduction

Java is great programming language for the development of enterprise grade applications. This programming Language is evolved from a language named Oak. Oak was developed in the early nineties at Sun Microsystems as a platform-independent language aimed at allowing entertainment appliances such as video game consoles and VCRs to communicate . Oak was first slated to appear in television set-top boxes designed to provide video-on-demand services. Oak was unsuccessful so in 1995 Sun changed the name to Java and modified the language to take advantage of the burgeoning World Wide Web.

Java is an object-oriented language, and this is very similar to C++. Java Programming Language is simplified to eliminate language features that cause common programming errors. Java source code files are compiled into a format called bytecode, which can then be executed by a Java interpreter.

Java is the most exciting object oriented programming language in computer programming landscape. Java provides diverse functionalities ranging from the addition of two numbers to write games, animations and a lot more. Just imagine and get it through java.

Present tutorial simply makes you familiar with the jargons of this language and enables a new comer to create programs in a short span of time. This tutorial explains the steps to configure the platform for compiling and running java program. Lot of efforts have been made to give easy explanation of java concepts through simple programs.

Installing Java

To compile and run a java program we need to install java platform. JDK (Java Development Kit). JDK is the basic set of tools required to compile and run java programs. This section enables you to download JDK and teaches you the steps to install it.

Download and Install JDK (Java Development Kit)

The latest version of jdk is 6 (update 1) at the time of writing the tutorial. You can download the latest version of jdk from http://java.sun.com/javase/downloads/index.jsp. Once you download the exe file you can now install it. Just follow as mentioned:

To install the jdk, double click on the downloaded exe file (jdk-6u1-windows-i586-p.exe)

Step 1. Double Click the icon of downloaded exe

Image:java1.gif

You will see jdk 6 update 1 window as shown below.

Image:java2.gif Image:java3.gif

Step 2: Now a "License Agreement" window opens. Just read the agreement and click "Accept" button to accept and go further.

Image:java4.gif

Step 3: Now a "Custom Setup" window opens.

Image:java5.gif

Step 4: Click on "Change" button to choose the installation directory. Here it is "C:\Program Files\ Java\jdk1.6.0_01". Now click on "OK" button.

Image:java6.gif

Clicking the "OK" button starts the installation. It is shown in the following figure.

Image:java7.gifImage:java8.gif

Step 5: Next window asks to install Runtime Environment.

Image:jre1.gif

Click the "Change" button to choose the installation directory of Runtime Environment. We prefer not to change it. So click "OK" button.

Image:jre2.gif

Step 6: Click "OK" button starts the installation.

Image:jre3.gif

Step 7: Now "Complete" window appears indicating that installation of jdk 1.6 has completed successfully. Click "Finish" button to exit from the installation process.

Image:installdirectory.gif

Step 9: To make available Java Compiler and Runtime Environment for compiling and running java programs , we set the system environment variables.

First of all select "My Computer" icon and right click the mouse button. Now click on "system Properties" option. It provides the "System Properties" window , click the 'Advanced' tab. Then Click the "Environment Variables" button. It provides "Environment Variables" window. Now select the path in System variables and click 'Edit' button. The"Edit System Variable" window will open. Add "c:\Program Files\Java\jdk1.6.0_01\bin" to 'variable value' and click 'Ok', 'Ok' and 'Ok' buttons.

Image:path.gif

Step 10: Now set the JAVA_HOME variable and set its value to " C:\Program Files\Java\jdk1.6.0_01 ". If this variable has not been declared earlier then create a new system variable by clicking on "New" button and give variable name as "JAVA_HOME" and variable value as " C:\Program Files\Java\jdk1.6.0_01 ". Now click "OK". This variable is used by other applications to find jdk installation directory. For example, Tomcat server needs "JAVA_HOME" variable to find the installation directory of jdk.

Image:JAVA-HOME.gif

Step 11: Now this is the final step to check that you have installed jdk successfully and it is working fine. Just go to the command prompt and type javac and hit enter key you will get the screen as shown below :

Image:javac.gif

Thats it. Now you are ready to create, compile and execute java programs.

Personal tools