Introduction to Eclipse - NCSU COE People · 3 v1.6 08/02/2006 5 Overview » IBM’s IDE History...

20
1 Introduction to Eclipse Introduction to Eclipse Ed Ed Gehringer Gehringer Using (with permission) slides developed by Using (with permission) slides developed by— Dwight Deugo ([email protected]) Dwight Deugo ([email protected]) Nesa Nesa Matic ( Matic ( [email protected] [email protected] ) Sreekanth Sreekanth Konireddygari Konireddygari (IBM Corp.) (IBM Corp.) 2 v1.6 08/22/2007 Overview of Eclipse Lectures 1. Overview 2. Installing and Running 3. Building and Running Java Classes 4. Refactoring 5. Debugging 6. Testing with JUnit 7. Version Control with CVS 1. Overview 2. Installing and Running 3. Building and Running Java Classes Lecture 1

Transcript of Introduction to Eclipse - NCSU COE People · 3 v1.6 08/02/2006 5 Overview » IBM’s IDE History...

Page 1: Introduction to Eclipse - NCSU COE People · 3 v1.6 08/02/2006 5 Overview » IBM’s IDE History 1994 VisualAge for Smalltalk 1996 VisualAge for Java 2001 Eclipse Project VisualAge

1

Introduction to EclipseIntroduction to EclipseEd Ed GehringerGehringerUsing (with permission) slides developed byUsing (with permission) slides developed by——

Dwight Deugo ([email protected])Dwight Deugo ([email protected])NesaNesa Matic (Matic ([email protected]@espirity.com))SreekanthSreekanth KonireddygariKonireddygari (IBM Corp.)(IBM Corp.)

2v1.6 08/22/2007

Overview of Eclipse Lectures

1. Overview2. Installing and Running3. Building and Running Java Classes4. Refactoring5. Debugging6. Testing with JUnit7. Version Control with CVS

1. Overview2. Installing and Running3. Building and Running Java Classes

Lecture 1

Page 2: Introduction to Eclipse - NCSU COE People · 3 v1.6 08/02/2006 5 Overview » IBM’s IDE History 1994 VisualAge for Smalltalk 1996 VisualAge for Java 2001 Eclipse Project VisualAge

2

3v1.6 08/02/2006

Module Road Map

1. OverviewBackgroundArchitectureComponentsUsage scenarios

2. Installing and Running3. Building and Running Java Classes4. Refactoring5. Debugging6. Testing with JUnit7. Version Control with CVS

4v1.6 08/02/2006

Overview » What is Eclipse?

Eclipse is an open-source project http://www.eclipse.orgConsortium of companies, including IBMLaunched in November 2001Designed to help developers with specific development tasks

Consists of four separate projects:Eclipse ProjectEclipse Tools ProjectEclipse Technology ProjectEclipse Web Tools Platform Project

Page 3: Introduction to Eclipse - NCSU COE People · 3 v1.6 08/02/2006 5 Overview » IBM’s IDE History 1994 VisualAge for Smalltalk 1996 VisualAge for Java 2001 Eclipse Project VisualAge

3

5v1.6 08/02/2006

Overview » IBM’s IDE History

1994VisualAge for Smalltalk

1996VisualAge for Java

2001Eclipse Project

VisualAge Micro Edition

6v1.6 08/02/2006

Overview » The Eclipse Platform Motivation

Application development tools construction supportIndependent tool vendors supportGUI and non-GUI application development supportNumerous content types support

Java, HTML, C, XML, ...Easy integration of toolsUse of Java language for writing the toolsMultiple operating systems support

Page 4: Introduction to Eclipse - NCSU COE People · 3 v1.6 08/02/2006 5 Overview » IBM’s IDE History 1994 VisualAge for Smalltalk 1996 VisualAge for Java 2001 Eclipse Project VisualAge

4

7v1.6 08/02/2006

Overview » Plug-in Architecture

Eclipse Platform

Platform Runtime

Tool(plug-in)

Tool(plug-in)

Tool(plug-in)

Workbench

Workspace

Help

Team

8v1.6 08/02/2006

Overview » WorkbenchRepresents the desktop development environment

It contains set of tools for resource managementIt provides common way of navigating through the resources

Multiple workbenches can be opened at the same time

Page 5: Introduction to Eclipse - NCSU COE People · 3 v1.6 08/02/2006 5 Overview » IBM’s IDE History 1994 VisualAge for Smalltalk 1996 VisualAge for Java 2001 Eclipse Project VisualAge

5

9v1.6 08/02/2006

Overview » Workspace

Represents users dataIt is a set of user-defined resources

FilesContain arbitrary number of bytes

FoldersContain other folders or files

ProjectsCollections of files and folders

10v1.6 08/02/2006

Overview » HelpUsed for creating and publishing documentationThere are two different documentation styles:

Help style documentation is published in the user guideAPI documentation is published in the programmer guide

Help content is in HTML formatHelp navigation is in XML format

Page 6: Introduction to Eclipse - NCSU COE People · 3 v1.6 08/02/2006 5 Overview » IBM’s IDE History 1994 VisualAge for Smalltalk 1996 VisualAge for Java 2001 Eclipse Project VisualAge

6

11v1.6 08/02/2006

Overview » Team

Provides support for:Versioning Configuration managementIntegration with team repository

Allows team repository provider to hook into the environment

Team repository providers specify how to intervene with resources

Has optimistic and pessimistic locking support

12v1.6 08/02/2006

Overview » How is Eclipse Used?

As an IDE - Integrated Development Environment

Supports the manipulation of various content typesUsed for writing code

As a product baseSupported through plug-in architecture and customizations

Page 7: Introduction to Eclipse - NCSU COE People · 3 v1.6 08/02/2006 5 Overview » IBM’s IDE History 1994 VisualAge for Smalltalk 1996 VisualAge for Java 2001 Eclipse Project VisualAge

7

13v1.6 08/02/2006

Overview » Eclipse as an IDE

Java Development Tooling (JDT) is used for building Java codeProvides set of workbench plug-ins for manipulating Java code

Java projects, packages, classes, methods, ....Java compiler is built in

Used for compiling Java codeCreates errors (special markers of code) if compilation fails

14v1.6 08/02/2006

Overview » Eclipse as a Product Base

Eclipse can be used as a Java product baseIts flexible architecture used as a product framework

Reuse plug-in architectureCreate new plug-insCustomize the environment

Page 8: Introduction to Eclipse - NCSU COE People · 3 v1.6 08/02/2006 5 Overview » IBM’s IDE History 1994 VisualAge for Smalltalk 1996 VisualAge for Java 2001 Eclipse Project VisualAge

8

15v1.6 08/02/2006

Module Road Map1. Overview2. Installing and Running Eclipse

Where to get Eclipse?What is the support for Eclipse?Installing EclipseRunning Eclipse

3. Building and Running Java Classes4. Refactoring5. Debugging6. Testing with JUnit7. Version Control with CVS

16v1.6 08/02/2006

Installing and Running Eclipse » Getting Eclipse

Page 9: Introduction to Eclipse - NCSU COE People · 3 v1.6 08/02/2006 5 Overview » IBM’s IDE History 1994 VisualAge for Smalltalk 1996 VisualAge for Java 2001 Eclipse Project VisualAge

9

17v1.6 08/02/2006

Installing and Running Eclipse » http://www.eclipse.org

Main point for finding Eclipse resourcesDownloadsArticlesDiscussion groupsBugs

Contains various resources for using EclipseContains references to other Eclipse related sites

18v1.6 08/02/2006

Installing and Running Eclipse »

Downloading Eclipse’s Install Zip File

Click on the Download from the main page on http://www.eclipse.org

Page 10: Introduction to Eclipse - NCSU COE People · 3 v1.6 08/02/2006 5 Overview » IBM’s IDE History 1994 VisualAge for Smalltalk 1996 VisualAge for Java 2001 Eclipse Project VisualAge

10

19v1.6 08/02/2006

Installing and Running Eclipse » Installing Eclipse

Unzip the downloaded file to the directory of your choice

20v1.6 08/02/2006

Installing and Running Eclipse » eclipse.exe

Eclipse is run by double-clicking on the eclipse.exe file

The file is located in the Eclipse installation directory

If there is no path set for javaw.exe program, the following dialog will come up

Page 11: Introduction to Eclipse - NCSU COE People · 3 v1.6 08/02/2006 5 Overview » IBM’s IDE History 1994 VisualAge for Smalltalk 1996 VisualAge for Java 2001 Eclipse Project VisualAge

11

21v1.6 08/02/2006

Installing and Running Eclipse » Missing a Java VM?

Download the latest Java Runtime Environment (JRE), http://java.sun.com/javase/downloads/index.jsp

22v1.6 08/02/2006

Installing and Running Eclipse » Running Eclipse

When Eclipse is run, a Workbench opens

Page 12: Introduction to Eclipse - NCSU COE People · 3 v1.6 08/02/2006 5 Overview » IBM’s IDE History 1994 VisualAge for Smalltalk 1996 VisualAge for Java 2001 Eclipse Project VisualAge

12

23v1.6 08/02/2006

Installing and Running Eclipse » Default Workspace

The default workspace is created when Eclipse runs for the first time

The workspace is located under \workspace\directory of Eclipse installation directoryFor example c:\eclipse\workspace

The workspace contains user defined data –projects and resources such as folders and files

24v1.6 08/02/2006

Installing and Running Eclipse »Running Different Workspace …

It is possible to run workspace other than default

-data argument must be used with eclipse.exeWorkspace location must be specified

Useful for grouping project specific dataMultiple workspaces can run at the same time

Page 13: Introduction to Eclipse - NCSU COE People · 3 v1.6 08/02/2006 5 Overview » IBM’s IDE History 1994 VisualAge for Smalltalk 1996 VisualAge for Java 2001 Eclipse Project VisualAge

13

25v1.6 08/02/2006

Installing and Running Eclipse »Running Different Workspace …

Customize your working directory by creating a shortcut identifying the eclipse.exe and the working directory

26v1.6 08/02/2006

Installing and Running Eclipse » Module Summary

In this module you have learned:What Eclipse is, its background and componentsHow Eclipse is usedHow to download, install and run EclipseHow to create and run multiple workspaces with Eclipse

Page 14: Introduction to Eclipse - NCSU COE People · 3 v1.6 08/02/2006 5 Overview » IBM’s IDE History 1994 VisualAge for Smalltalk 1996 VisualAge for Java 2001 Eclipse Project VisualAge

14

27v1.6 08/02/2006

Module Road Map1. Overview2. Installing and Running3. Building and Running Java Classes

Developing Java applicationsProjects, packages, classesBrowsing Java codeSearching Java codeOrganizing Java codeUsing Code AssistRunning Java applicationsScrapbook

4. Refactoring5. Debugging6. Testing with JUnit7. Version Control with CVS

28v1.6 08/02/2006

Building and Running Java Classes »

Java Development Tooling - JDT

Eclipse’s Java Development Environment is often referred to as JDT – Java Development Tooling

Using the JDT you can do following with the Java programs:

WriteCompileTestDebug

Page 15: Introduction to Eclipse - NCSU COE People · 3 v1.6 08/02/2006 5 Overview » IBM’s IDE History 1994 VisualAge for Smalltalk 1996 VisualAge for Java 2001 Eclipse Project VisualAge

15

29v1.6 08/02/2006

Building and Running Java Classes » Perspectives

When developing Java code commonly used perspectives are:

Java PerspectiveDesigned for working with Java projects

Java Browsing PerspectiveDesigned for browsing structure of Java projects

Java Type Hierarchy PerspectiveDesigned for exploring type hierarchy

Debug PerspectiveDesigned for debugging Java programs

30v1.6 08/02/2006

Building and Running Java Classes » Java Perspective

Contains:Editor areaPackage Explorer ViewHierarchy ViewOutline ViewProblems View

Page 16: Introduction to Eclipse - NCSU COE People · 3 v1.6 08/02/2006 5 Overview » IBM’s IDE History 1994 VisualAge for Smalltalk 1996 VisualAge for Java 2001 Eclipse Project VisualAge

16

31v1.6 08/02/2006

Building and Running Java Classes »

Java Browsing Perspective

Contains:Editor areaProjects ViewPackages ViewTypes ViewMembers View

32v1.6 08/02/2006

Building and Running Java Classes »

Java Type Hierarchy Perspective

Contains editor area and Hierarchy View

Page 17: Introduction to Eclipse - NCSU COE People · 3 v1.6 08/02/2006 5 Overview » IBM’s IDE History 1994 VisualAge for Smalltalk 1996 VisualAge for Java 2001 Eclipse Project VisualAge

17

33v1.6 08/02/2006

Building and Running Java Classes »

New Project Preferences

You can set global preferences for a projectSelect Window »Preferences to get Preferences ViewGood idea to separate your Java files into source and compiled directories (srcand bin)This action only needs to be done onceDone for all subsequent projects

34v1.6 08/02/2006

Building and Running Java Classes »

Creating Java Project

Project used to organize resources (source, class, icons) for a projectTo create Java project:

Select File » NewProject… from the menuThe New Project wizard comes upSelect Java ProjectClick Next

Page 18: Introduction to Eclipse - NCSU COE People · 3 v1.6 08/02/2006 5 Overview » IBM’s IDE History 1994 VisualAge for Smalltalk 1996 VisualAge for Java 2001 Eclipse Project VisualAge

18

35v1.6 08/02/2006

Building and Running Java Classes » New Project Wizard

Specify Project NameClick Next

36v1.6 08/02/2006

Building and Running Java Classes » Java SettingsSpecify Java settings

Output folder (where compiled files will be stored)Click on Libraries tab to specify dependencies such as

External jar files project depends onClasses from other projects that are referenced in the project

Click Finish

Page 19: Introduction to Eclipse - NCSU COE People · 3 v1.6 08/02/2006 5 Overview » IBM’s IDE History 1994 VisualAge for Smalltalk 1996 VisualAge for Java 2001 Eclipse Project VisualAge

19

37v1.6 08/02/2006

Building and Running Java Classes » Project Properties

You can change the Java build path at any time

Choose Properties from the context menu on the project

38v1.6 08/02/2006

Building and Running Java Classes » Creating Packages

Package contains Java class filesTo create a package for a project:

Select the project in the Package ExplorerChoose New » Packagefrom the context menuNew Java Package window appearsSpecify package nameClick Finish

Page 20: Introduction to Eclipse - NCSU COE People · 3 v1.6 08/02/2006 5 Overview » IBM’s IDE History 1994 VisualAge for Smalltalk 1996 VisualAge for Java 2001 Eclipse Project VisualAge

20

39v1.6 08/02/2006

Building and Running Java Classes » Creating Classes

To create a class in a package:

Select the package in the Package ExplorerChoose New »Class from the context menuThe Class wizard comes upSpecify class details (Name, Modifiers & Superclass)Click Finish

40v1.6 08/02/2006

Exercise 1

Create a new Java application Project titled EgApp.Create a new Package csc517 in the Project EgApp.Create a new class titled MainClass with the main() method in the Package csc517.