Sunday, July 17, 2011

Eclipse IDE – Tutorial


Introduction:
This tutorial explains how to use Eclipse IDE for software development. Eclipse is a multi-language software development tool developed by Object Technology International (OTI). It is mostly used for Java development but we can extend its usage by means of various plugins and do programming in other languages as well including C, C++, PHP, COBOL, Perl, Python etc. This tutorial explains installation of eclipse, configuring eclipse, creation of java project / programs, execution of java programs. Thus it’s a complete guide for beginners.

Eclipse Installation:
Eclipse installation is very simple. Eclipse requires an installed Java Runtime. Java 1.6 is recommended. Download "Eclipse IDE for Java Developers" from the website “http://www.eclipse.org/downloads/”.  Unzip it. Eclipse is now ready to use.

Starting Eclipse:
Double-click on “eclipse.exe” in the directory where you unzipped it. Workspace Launcher will then prompt for workspace location. Workspace is a place where you store your Java project. Select an empty directory and click ok.


Eclipse will show welcome page. Close it to go to the workbench. The term workbench is used to describe the environment in which all of your work will be done. It has menu bar and tool bar.  

Eclipse User Interface:
Eclipse user interface is very flexible, extensible and rich featured. Eclipse user interface components are explained below with diagrams.

The Workbench: The workbench is a parent window where application development work is done. The workbench is a collection of windows. Detailed diagram of workbench is as follows:

The Menu bar and Tool bar: They are horizontal bars and have many shortcuts to perform common tasks. Menu bar usually contains the File, Edit, Navigate, Project, Window, Help top-level menus. Tool bar has shortcuts to debug tool, search tool, open web browser, launch the web services explorer, print, open task and launch application server. 

Perspective: A perspective is a visual container for a set of views and editors. You can change the layout within a perspective (close / open views, editors, change the size, change the position, etc.). Eclipse allows you to switch to another perspective via the menu Window --> Open Perspective --> Other. For Java development you usually use the "Java Perspective".


Views: Views are designed to support interaction with the information in your workbench. Eclipse is designed to be extensible, so views can be designed to show nearly any kind of information. We use them to navigate a hierarchy of information, open an editor, or view properties for the active editor. Only one instance of a view may exist in a perspective. A view must be able to be opened in more than one perspective. A view can be opened from the Window --> Show View menu.
Editor:  This window is used to do development work for viewing and editing documents. If more than one document is opened then we get a document tabbed view to manage all opened documents. Editor is used to write source code and debug it.
Create Java project:
Use File menu (File --> New --> Project) given in menu bar to create new project. This will open a small window which shows a list of projects. Select “Java Project” among them and press “Next”. Specify project name in next window and press “Finish”.




Create Java Package, Java Class and Run a small Java Program:
As a best practice java classes are organised in java packages. Programmers also typically use packages to organize classes belonging to the same category or providing similar functionality.
Create java package: Select the folder src, right mouse click on it and select New --> Package. Specify name of package and press “Finish”.




Create Java Class: Select package, right mouse click on it and select New --> Class. Specify name of Java class and press “Finish”. Select checkbox to generate comments and also check which method stubs you would like to create.


 

Write java source code in editor and save all changes using (ctrl + s).

 

Run Java Program:

To run this java program either select java class file and do right mouse click or directly do right mouse click on editor. Choose Run as Java application. Output of program will be shown on console below editor.

 




Congratulations! We’ve created Java project and ran a simple java program. We’ve learnt basics of Eclipse in this tutorial. This brings end to this tutorial.


1 Responses to “Eclipse IDE – Tutorial”

Javin @ String split Java said...
December 14, 2011 at 5:11 PM

Nice tutorial Sandeep, I have also blogged on Eclipse in my blog as:

10 tips on Java debugging in Eclipse
Top 30 Eclipse keyboard shortcuts
you may find useful.


Post a Comment

© 2011 a2ztechguide.com • All rights reserved.
Blogger Template by Bloggermint