03-Java IDE.v3.1

download 03-Java IDE.v3.1

of 30

Transcript of 03-Java IDE.v3.1

  • 8/8/2019 03-Java IDE.v3.1

    1/30

    Java IDEJava IDE

    Dwight Deugo ([email protected])Dwight Deugo ([email protected])

    Nesa Matic ([email protected])Nesa Matic ([email protected])

    www.espirity.com

  • 8/8/2019 03-Java IDE.v3.1

    2/30

    2 2003-2005, Espirity Inc.

    Additional Contributors

    None asofSeptember, 2005

  • 8/8/2019 03-Java IDE.v3.1

    3/30

    3 2003-2005, Espirity Inc.

    Module Overview

    1. Building and Running Java Classes

  • 8/8/2019 03-Java IDE.v3.1

    4/30

    4 2003-2005, Espirity Inc.

    Module RoadMap

    1. Building and Running Java Classes Developing Java applications

    Projects, packages, classes

    Browsing Java code

    Searching Java code

    Organizing Java code

    Using Code Assist

    Running Java applications Scrapbook

  • 8/8/2019 03-Java IDE.v3.1

    5/30

    5 2003-2005, Espirity Inc.

    Java DevelopmentTooling - JDT

    EclipsesJava DevelopmentEnvironmentisoften referredto asJDT Java DevelopmentTooling

    Using theJDT youcan dofollowing withtheJava programs:

    Write

    Compile

    Test Debug

  • 8/8/2019 03-Java IDE.v3.1

    6/30

    6 2003-2005, Espirity Inc.

    Perspectives

    When developing Java codecommonlyusedperspectives are:

    Java Perspective

    Designedforworking withJava projects Java Browsing Perspective

    Designedforbrowsing structureofJava projects

    Java Type HierarchyPerspective

    Designedforexploring typehierarchy

    Debug Perspective

    Designedfordebugging Java programs

  • 8/8/2019 03-Java IDE.v3.1

    7/30

    7 2003-2005, Espirity Inc.

    Java Perspective

    Contains: Editor area

    Package ExplorerView

    Hierarchy View

    Outline View

    Problems View

  • 8/8/2019 03-Java IDE.v3.1

    8/30

    8 2003-2005, Espirity Inc.

    Java Browsing Perspective

    Contains: Editor area

    Projects View

    Packages View

    Types View

    Members View

  • 8/8/2019 03-Java IDE.v3.1

    9/30

    9 2003-2005, Espirity Inc.

    Java Type HierarchyPerspective

    Containseditor area and Hierarchy View

  • 8/8/2019 03-Java IDE.v3.1

    10/30

    10 2003-2005, Espirity Inc.

    BuildPathProjectPreferences

    Youcan setglobalpreferencesfor a project SelectWindow ->

    Preferences -> General ->Java to getJavaPreferences

    Goodidea toseparateyourJava filesintosource andcompileddirectories (srcandbin)

    This action only needsto

    bedoneonce Donefor all subsequentprojects

  • 8/8/2019 03-Java IDE.v3.1

    11/30

    11 2003-2005, Espirity Inc.

    Creating Java Project

    Projectusedtoorganizeresources (source, class,icons) for a project

    TocreateJava project: SelectFile New Project

    fromthemenu TheNewProjectwizardcomesup

    SelectJava Java Project

    ClickNext

  • 8/8/2019 03-Java IDE.v3.1

    12/30

    12 2003-2005, Espirity Inc.

    NewProjectWizard

    SpecifyProjectName ClickNext

  • 8/8/2019 03-Java IDE.v3.1

    13/30

    13 2003-2005, Espirity Inc.

    Java Settings

    SpecifyJava settings Outputfolder (wherecompiledfileswill bestored)

    External jarfilesprojectdependson

    Classesfromotherprojectsthatarereferencedin theproject

    ClickFinish

  • 8/8/2019 03-Java IDE.v3.1

    14/30

    14 2003-2005, Espirity Inc.

    ProjectProperties

    Youcan changetheJava buildpath atanytime ChooseProperties fromthecontextmenuwhileselecting theproject

  • 8/8/2019 03-Java IDE.v3.1

    15/30

    15 2003-2005, Espirity Inc.

    Creating Packages

    PackagecontainsJavaclassfiles

    Tocreate a packagefor a project:

    Selectthesrcfolderintheproject

    ChooseNew Packagefromthecontextmenu

    Specifypackage name

    ClickFinish

  • 8/8/2019 03-Java IDE.v3.1

    16/30

    16 2003-2005, Espirity Inc.

    Creating Classes

    Tocreate a classin apackage:

    Selectthepackage

    ChooseNew Class

    fromthecontextmenu

    The Classwizardcomesup

    Specifyclassdetails

    ClickFinish

  • 8/8/2019 03-Java IDE.v3.1

    17/30

    17 2003-2005, Espirity Inc.

    Using CodeAssist

    When activated, code assistopens a listofavailablecodecompletions

    CodeAssistactivatesbyCrtl+Space Activates automaticallywhen a message needstobesentto anobject(afterthedotistyped)

  • 8/8/2019 03-Java IDE.v3.1

    18/30

    18 2003-2005, Espirity Inc.

    Using Quick Fix

    Useful ifJava compilershowserrors Givesoptionsforfixing theerrors

    ActivatedthroughEdit Quick Fix menuoption

    Errorindication

  • 8/8/2019 03-Java IDE.v3.1

    19/30

    19 2003-2005, Espirity Inc.

    Searching forJava Classes

    When developing Java application a goodsearchmechanismis veryimportant

    Youoften searchforclass, methoddeclarations, andreferences

    Itisimportanttobe abletofindthingsquickly

    EclipseJava Searchmechanismis veryextensive

    Itallowsyoutosearchfor:

    Types, methods, constructors, packages, andfields Declarations, Implementers, References

    In thescopeofWorkspace, Working Set, or SelectedResources

  • 8/8/2019 03-Java IDE.v3.1

    20/30

    20 2003-2005, Espirity Inc.

    Organizing Java Code

    Eclipsecomeswithextensivesupportfororganizing andrefactoring Java code

    Itispossibleto:

    Generate getters andsettersforthefields Organizemissing importstatements

    Movefields, methods, classes

    Renamemethods, classes, packages

  • 8/8/2019 03-Java IDE.v3.1

    21/30

    21 2003-2005, Espirity Inc.

    Generating Getters and Setters

    Availableforcreatinggetandsetmethodson thefields

    Itsupports

    encapsulation ActivatedbychoosingSource Generate

    Getter and Setterfrom

    theeditorscontextmenu

  • 8/8/2019 03-Java IDE.v3.1

    22/30

    22 2003-2005, Espirity Inc.

    Refactoring

    AvailablefromtheR

    efactorcontextmenuoptionin theeditor

    Helpswithrefactoring Java code

    Allowsfor:

    Renaming Methods, fields, packages, projects, parameters, or local

    variables

    Changing ofmethodsignature

    Pull up a fieldormethod (intosuperclass)

    Pushdown a fieldormethod (intosubclass) ExtractInterface (generateinterfacefromclass)

    Generalizetype (changetypeoffields andmethods)

  • 8/8/2019 03-Java IDE.v3.1

    23/30

    23 2003-2005, Espirity Inc.

    Running Java Classes

    To Run Java application ChooseRun Run fromthemenu

  • 8/8/2019 03-Java IDE.v3.1

    24/30

    24 2003-2005, Espirity Inc.

    Console View

    RepresentsstandardJava console Opensbydefaultwhen standardJava outputisused

    Can alsobeopen fromWindow Show View menu

    System.out.println("this is a demo");

  • 8/8/2019 03-Java IDE.v3.1

    25/30

    25 2003-2005, Espirity Inc.

    Scrapbook

    Allowsforwriting andexecuting ofJavacode

    Veryuseful forquicktestofJava codethatyou

    write TheJava codein the Scrapbookcan be:

    Displayed as a string when evaluated

    Inspectedwhen evaluated

    Opens an Inspector viewwhereyoucan seereturningobjectfromevaluation and all containing fields

    Executed

  • 8/8/2019 03-Java IDE.v3.1

    26/30

    26 2003-2005, Espirity Inc.

    Scrapbook

    Itiscreatedbyselecting aprojectandchoosing New Other Java Java

    Run/Debug Scrapbook

    Page fromthePackageExplorerscontextmenuandthen entering thenameofthepage

    Yourscrapbookpagewill

    become a resourcein yourproject

  • 8/8/2019 03-Java IDE.v3.1

    27/30

    27 2003-2005, Espirity Inc.

    Scrapbook

    Toopen thescrapbookpagejustclickon theresource

    Itopensup like a Javasourcefileeditor

    TypeJava code andselectthecontext

    menuto DisplayorInspect

  • 8/8/2019 03-Java IDE.v3.1

    28/30

    28 2003-2005, Espirity Inc.

    Scrapbook

    Class namesmustbefullyqualifiedin whatyoutype

    Setimportstomake lifeeasier

    Thinkofyourscrapbook asa pagethatEclipsewilltakethesourceyoutype,wrapitin a classwithyoursourcein themain menu,

    then compile andexecute

  • 8/8/2019 03-Java IDE.v3.1

    29/30

    29 2003-2005, Espirity Inc.

    Summary

    Youhave learned: Howtocreateprojects, packages andclasses

    HowtobrowseJava code andsearchforJava

    code Howtousecoding assistance

    HowtoorganizeJava code

    Howtorun Java code

    Howtousethe Scrapbook

  • 8/8/2019 03-Java IDE.v3.1

    30/30

    30 2003-2005, Espirity Inc.

    Labs!

    Lab: Building and Running a Java Application