Print - Eclipse IDE Tutorial

Embed Size (px)

Citation preview

  • 5/14/2018 Print - Eclipse IDE Tutorial

    1/39

    07103/2012 Eclipse IDETutorial

    (j)vogella Eclipse IDE TutorialTutorial Lars Vogel

    383 Version 2.7Copyright 2007 - 2011 Lars Vogel16.12.2011Revision HistoryRevision 0.1 18.07.2007

    Created

    18.05.2008 - 16..12.2011

    hllnfixFlSand Flnh~nr.FlmFlntsCj)vogel/aome Tutorials Trainings Books Social

    Eclipse Java IDEThis tutorial describes the usage of Eclipse as a Java IDE. It describes the installation of Eclipse,Java programs and tips for using Eclipse. This tutorial is based on Eclipse 3.7 (Indigo).

    Table of Contents1. What is Eclipse?2. Getting started

    2.1. Java2.2. Install Eclipse2.3. Start Eclipse3. Eclipse UIOverview

    3.1. Workspace3.2. Parts3.3. Perspective3.4. Eclipse IDE Perspectives3.5. Java Perspective and Package Explorer3.6. Linking the package explorer with the code editor3.7. Problems view

    4. Create your first Java program4.1. Create project4.2. Create package4.3. Create Java class4.4. Run your project in Eclipse4.5. Prepare to run program outside Eclipse (create jar file)4.6. Run your program outside Ecl ipse

    5. Content Assist, Quick Fix and Class Navigation5.1. Content assist5.2. Quick Fix

    www.vogella.de/articles/Eclipse/article.html#updatemanager

  • 5/14/2018 Print - Eclipse IDE Tutorial

    2/39

    07103/2012 Eclipse IDETutorial6. Opening a class7. Generating code8. Refactoring9. Eclipse Shortcuts10. Using jars (libraries)

    10.1. Adding a library (. jar ) to your project10.2. Show source code for jar10.3. Add the Javadoc for a jar11. Updates and Installation of Plugins

    11.1. Eclipse Update Manager11.2. Manual installation of plug-ins (dropins folder)11.3. Eclipse Marketplace11.4. Restart required?12. Efficiency Settings

    12.1. Eclipse Preferences12.2. Automatic placement of semicolon12.3. Imports and Source code formating12.4. Filter import statements12.5. Templates12.6. Code Templates12.7. Export I Import Preferences12.8. Task Management12.9. Working Sets13. Eclipse Help and Community

    13.1. Eclipse Bugs13.2. Online documentations13.3. Asking (and answering) questions13.4. Webresources14. Nex t steps15. Thank you16. Questions and Discussion17. Links and Literature

    17.1. Source Code17.2. Eclipse Resources17.3. vogella Resources

    1. What is Eclipse?Eclipse is created by an Open Source community and is used in several different areas, e.g. as aenvironment for Java or Android applications. Eclipse roots go back to 2001.Most people know Eclipse as an integrated development environment (IDE) for Java. Today it is thdevelopment environment for Java with a marketshare of approx. 65%.The Eclipse project is governed by the Eclipse Foundation. The Eclipse Foundation is a non-profit,supported corporation that hosts the Eclipse projects and helps to cult ivate both an open source coecosystem of complementary products and services.Eclipse can be extended with additional functionalit ies. Several Open Source projects and companextended Eclipse with additional components. It is also possible to use Eclipse as a basis for creapurpose applications (Eclipse Rep).

    2. Getting started2.1. Java

    www.vogella.de/articles/Eclipse/article.html#updatemanager

  • 5/14/2018 Print - Eclipse IDE Tutorial

    3/39

    07103/2012 Eclipse IDE TutorialEclipse requires an installed Java Runtime. Irecommend to use Java 7 (also known as Java 1.7) oJava comes in two flavors, the Java Runtime Environment (JRE) and the Java Development Kit (JDcontains only the necessary functionality to start Java programs, while the JDK contains in additiontools.Eclipse contains its own development tools, e.g. Java compiler. Therefore for this tutorial it is sufficJRE.The JDK is required if you compile Java source code outside Eclipse and for advanced developmeexample if you use automatic builds or if you develop web development. These scenarios are not ctutorial.Java might already be installed on your machine. You can test this by opening a console (if you areWin+R, enter "cmd" and press Enter) and by typing in the following command:

    I java -vers icnIf Java is correctly installed you should see some information about your Java installation. If the comthe information that the program could not be found, you have to install Java. A Google search for "on ..." should result in helpful links. Replace "..." with your operating system, e.g. Windows, Ubuntu,2.2. Install EclipseTo install Eclipse download the package "Eclipse IDE for Java Developers" from the websitehttp://www.eclipse.org/downloads and unpack it to a local directory.The download is a "zip" file. Most operating system can extract zip files in their file browser, e.g. Wmouse click on the file and selecting "Extract all...". If in doubt, search via Google for "How to unzipreplacing "..." with your operating system.Use a directory path which does not contain spaces in its name, as Eclipse sometimes has probleAfter unpacking the download, Eclipse is ready to be used; no additional installation procedure is2.3. Start EclipseTo start Eclipse double-click on the file eclipse. exe (Microsoft Windows) or eclipse (Linuxldirectory where you unpacked Eclipse. The system will prompt you for a workspace. The workspawhere you store your Java projects (more on workspaces later). Select an empty directory and pre

    Ie-OK-]1 Cancel ~

    Select a workspaceEPPRCP Package stores your projects in a folder cal led a workspace.Choose a workspace folder to use for this session,

    Workspace: I [\Documents and Settings\vogella\DesktoQ\Documents\16 Ecli~jects\02 MIF 1 [ Browse", ~D Use this as the default and do not ask again

    www.vogella.de/articles/Eclipse/article.html#updatemanager

    http://www.eclipse.org/downloadshttp://www.eclipse.org/downloads
  • 5/14/2018 Print - Eclipse IDE Tutorial

    4/39

    07103/2012 Eclipse IDE TutorialEclipse will start and show the Welcome page. Close the welcome page by pressing the "X" besid

    Search Project Run Window Help

    3. Eclipse UI OverviewEclipse provides Perspectives, Views and Edi tors. Views and Edi tors are grouped inPerspecti ves. All projects are located in a workspace.3.1. WorkspaceThe workspace is the physical location (file path) you are working in. You can choose the workspaof Eclipse or via the menu ( File - Switch Workspace - Others. All your projects, source files, imartifacts will be stored and saved in your workspace.You can predefine the workspace via the startup parameter -da ta path_to _workspace, e.g.c:\eclipse.exe -data "c:\temp".

    Please note that you have to put the path name into double quotes.To see the current workspace directory in the title of Eclipse use -showLocation as an addition3.2. PartsParts are user interface components which allow to navigate and modify data. Parts are typicalViews and Edi tors.

    www.vogella.de/articles/Eclipse/article.html#updatemanager

  • 5/14/2018 Print - Eclipse IDE Tutorial

    5/39

    07103/2012 Eclipse IDE Tutorial

    Part

    Part

    Part

    The distinction intoViews and Edi tors is primary not based on technical differences, but an a dusing and arranging these Parts.A View is typically used to work on a set of data, which might be hierarchical structured. If data isView, this change is typically directly applied to the underlying data structure. Views sometimes aEditor for a selected set of the data.An example for aView is the Java Package Explorer, which allow you browse the files of Eclipsechoose to change data in the Package Explorer, e.g. if you rename a file, the file name is directly cfilesystem.Editors are typically used to modify a single data element, e.g. a file ora data object. To apply tin an editor to the data structure, the user have to explicit ly select a "Save" command, e.g. Menu enEditors were traditionally placed in a certain area, called the "editor area". Until Eclipse 4 this wlimitation, it was not possible to move an Edi tor out of this area; Eclipse 4 allows to place Editoposit ion in a Perspecti ve.For example the Java Editor is used to modify Java source files. Changes to the source file are onuser selects the "Save" command.3.3. PerspectiveA Perspecti ve is a visual conlainerfor a set of Parts.You can change the layout and content within a Perspective by opening or closing Parts andthem.As of Eclipse 4.x Perspectives are optional elements for Eclipse based applications. The EclipsePerspecti ves to arrange Parts for different development tasks.3.4. Eclipse IDE PerspectivesThe Eclipse IDE ships with several default Perspecti ves.

    www.vogella.de/articles/Eclipse/article.html#updatemanager

  • 5/14/2018 Print - Eclipse IDE Tutorial

    6/39

    07103/2012 Eclipse IDE TutorialFor Java development you usually use the Java Perspective, but Eclipse has much more prePerspectives, e.g. Debug, Git Repositories, CVS Repositories.Eclipse allows you to switch to another perspective via the menu Window - Open Perspective -A common problem is that you mis-configured your Perspective, e.g. by closing a View. You cPerspecti ve to its original state via the menu Window - Reset Perspective.

    3.5. Java Perspective and Package ExplorerThe default Perspecti ve for Java development can be opened via Window - Open PerspectiveOn the left hand side, this perspective shows the "Package Explorer" View, which allows to browsprojects and to select the components you want to work on via double-click.For example to open a Java source file, open the tree under src, select the corresponding. javaclick it. This will open the file in an Edi tor.The following picture shows the Eclipse IDE in its standard Java perspective. The "Package ExploInthe middle you have the open Edi tor for a Java source file. If several Edi tors would be openstacked in the same place and you could switch between them by clicking on the next Edi tor. Allsame part of the Eclipse IDE; this part is called the "editor area".To the right and below the editor area you find more Views which were considered useful by the dperspective. For example the "Console" view shows the output of System. out statements in you;;!; Je v a- ode:vog:e:llaeclipse.idefirst/src/de/voge lle/eclipse/ide/f r,tJMyFirstClassjava - Eel i ,s eF ile E dit Re fac tor Sourc e Run N avigate Search Proje c t W indow H e lprj" '~~~11ill l e Ii l@ J S IQ i l ~ . . .o ...~ ...8 5 ' G ' ' ' '@ ~ [9 t9 ... 1 ~ _A iiil'~ [I D l ' Q ] . . . O J . . . ~

  • 5/14/2018 Print - Eclipse IDE Tutorial

    7/39

    07103/2012 Eclipse IDE Tutorial3.6. Linking the package explorer with the code editorThe Package Explorer allows displaying the associated file from the currently selected editor. Forworking on Foo. java and you change in the editor to Var. java then the corresponding file willthe "Package explorer" View.To activate this behavior, press the button "Link with Editor" in the "Package explorer" View.

    ~ P ackage Exp lore r l= Sf f i G J im ag es 9 75! . . . . . [ R I a rt ic le . x ml 9 753.7. Problems viewSooner or later you will run into problems with your code or your project setup. To view the problemyou can use the "Problems" View which is part ofthe standard Java Perspective. If it is closed youWindows ---+ Show View ---+ Problems.1 99 e rro rs , 1 47 w a rn in gs, 0 o th ersDescr ipt ion I Resource I Path .. .. I Locat. . . I Type

    d e, vo ge lla " , lin e 7 P lug -d e, vo ge lla " , lin e 1 0 P lug -de , voge lla " , lin e 9 Javade , voge lla " , lin e 5 Javade ,voge lla " , lin e 13 Java

    B Q i E rro rs (1 99 it em s )~ Bun dle 'R fcC om mon ' can no t be resclve MANIFEST,MF~ B un dle 'T MR fc con ne ctor' c an n ot be re MANIFEST,MF~ La ne Se le ctio n c an no t be re so lve d to a . ILa ne Da o,ja va~ T he im po rt s ele ct io n c an n ot b e re so lv e, I La ne D ao ,ja va~ L an e Se le ctio n c an n ot b e re so lv ed t o a . L an e Do wn lo ad Da o,ja va

    You can configure the content of the "Problems" View. For example, to display the problems fromselected project, select "Configure Contents" and set the Scope to "On any element in the same p

    .,-V=ElShowG ro up B yS ort B yN ew P ro blem s V ie wCon f igu re Con ten t s ",Co lumns" ,Pre fe rencesF oc us o n A c tiv e T as k

    www.vogella.de/articles/Eclipse/article.html#updatemanager

  • 5/14/2018 Print - Eclipse IDE Tutorial

    8/39

    07103/2012 Ec li pse IDE Tu to ri al~ Configure Contents ~[QConf igurabons:

    New" .....ScopeoO n an y e le me ntoO n a ny e le me n t in sa me proje ctoO n s ele ct ed e le m e nt o nly@ O n s ele ct ed e le m e nt a nd its c hild re noO n w orkin g se t: W in dow W orkin g Se t

    [ Se le c t. ......Description:Descr ipbon I con ta ins v I L-

    ~ A ll ErrorsD Wa rn in g s o n S e le c bo nRemove

    W he re se ve rity is: ~ Error DWarn ing DIn fo....Types

    o Match a l l con ftgur abons@ Ma t ch a n y co n fig u ra b on

    m ~ API Proble msm ~ APT P roblems~ A n t B uild file P ro ble m~ C he cksty le P roble m~ C la ss pa th D e pe n de n cy V alid ato r M e ss~ DTD Problem~ D rive r Proble ms~ EA R V alida tor M essa ge~ E JB V alid ato r M e ss ag e

    ~ [ Se le c t8 l Dese le c

    OK 11 [ Can

    4. Create your first Java programThe follow ing describes how to create a m inim al Java program using Eclipse. It is tra ditio n in th e pto create a sm all program w hich w rites "H ello W orld" to the console. W e w ill adapt th is tradition anE clip se !" to th e c on so le .

    4.1. Create projectSelect from the m enu File ---+ New ---+ J av a p ro je ct. E nte r de.vogella. eclipse. ide. firstnam e. S elect the flag "C reate separate folders for sources and class files".

    www.vogella.de/art icles/Eclipse/art icle.html#updatemanager

  • 5/14/2018 Print - Eclipse IDE Tutorial

    9/39

    07103/2012 Eclipse IDE TutorialI~Ne w Java P [Ili~ct { ;J~~lCreate a Java Project r C 7re ate a Java pro je ct in the w orkspace or in an exte rn al loca tion .!:r oje ct n am e : I d e . v og e lla . e c lip se . id e . Fir st IConten t soC re ate n ew p ro je ct in ~ orks pa ceoC re ate p ro je ct F ro m e !;is tin g s ou rc eQ. i rec tory : I C :\D ocu me nts an d S ettin gs\d 034 79 7\D esk to p\D ocum en ts\16 E dip s I B lo ws e . ..JR EoUse an e xe cut ion e n~iron me nt JRE : 1 JavaSE -1.6 I , v loU ~e a p roje ct s pe ciF ic J RE : 1 jdkl .6.0_13

    1IoUs e d e F 9_ u lt J R E ( cu rr e n tl y ' jd k l. 6 .0 _ 13 ') C on lio ur e J RE s . ..

    P ro je c t la yo ut 1!"Ise pro je ct Fo ld er as ro ot F or s ou rce s a nd cla ss F ile s C ;;_ re ate se pa ra te F old er s F or s ou rc es a nd c la ss F ile s C on F ig ur e d e Fa ult . ..W or kin g s ets

    1Df . i ~ ~ : P ; : 9 j ~ ~ 1 : ~ q : : 0 . : 9 ; : 0 . ~ ! i : ~ ~ ~ ~ jWQ rk in g s e ts : IBirt v i S~ le c t . . . ]

    , < !2_ack [ [l j_ext> I lL E in is h-- := Jl [ Ca nc e l I lPress finish to create the project. A new project is created and displayed as a folder. Open thede. vogella. eclipse. ide. first folder and explore the content of this folder.4.2. Create packageCreate a new package. A good convention is to use the same name for the top package and thetherefore the package de. vogella. eclipse. ide. first.Select the folder src, right click on it and select New ---+ Package.8 16 de.vogel la .ecl ipse.ide.First 1 1 -~, . -,;".[51 ;~ Ne w Q J av a P ro je c t$13 iiiW e b A pp lic atio n P ro je cti . . [R ] O pe n in Ne w W in dow

    L . I ! J O pe n T yp e H ie ra rc hy F4 rjP ro je c t . ..Show In A lt+shiF t+w fe Package I I

    www.vogella.de/articles/Eclipse/article.html#updatemanager

  • 5/14/2018 Print - Eclipse IDE Tutorial

    10/39

    07103/2012 Ec li pse IDE Tu to ri al

    Java PackageCreate a new Java package,

    Creates folders corresponding to packages,Source folger: I de,vogella,eclipse,ide,firstisrcNa!![e: I de, vogella, eclipse, ide, Firstl

    I [ BrQwse" ,I

    4.3. Create Java classW e w ill now create a Java class, R ight click on your package and select New ---+ Class,8 (?\ de, voqella. eclipse, ide, First

    ~~srci Lm [de,vogella,eclipse,ide,Firstl$...?, .settinqs New ~@ g Java Project:~ .desspeth Open in New Window fjWeb Application ProjectL . . . [!J ,project L 5 Project",Open Type Hierarchy F4

    Show In Alt+shift+w ~ E l i ' Package~Copy ctrl+C G ' Class I

    EnterMyFirstClass as the class nam e and select the flag "public static void m ain (S tringO args

    www.vogella.de/art icles/Eclipse/art icle.html#updatemanager

  • 5/14/2018 Print - Eclipse IDE Tutorial

    11/39

    07103/2012 Ec li pse IDE Tu to ri ali , ! : New JdVd Cla~~ ~~~1Java Class ereate a new Java cia.Source folQ_er: I de. voqelle.eclipse.ide.firstrsrc I [ BrQ.wse... IPacisage: I de.vogella. eclipse. ide. first I [ Bro~se ... ID Enclosing t\j le: I I [ Bro~se ... I

    I I MyFirstClass Ia!!le: IModifiers: @g_ublic Odefa'd,lt pri~ate protected

    Dabs~ract Dfina[ stati~::l,uperclass: I java.lang.Object I [ Brows~ ... I[nterf aces:

    I[I

    ~dd ... IRemove I

    Which method stubs would YO U l ike to create?I ' 1p ' 1 j . t J . n . ~ . .~~:'I~i~.yo.ic:l.I"I1.~.i.r1{?.t.ri.r1gD.:'Ir.g~yD ~onstructors f rom superdesso InQerited abstract methods

    Do you want to add comments? (Conf igure templates and defau lt value ~D .enerate comments

    [[ Einish J[ Cancel IThis creates a new file and opens an Edi tor to ed it the source code of this file . W rite th e fo llo win

    p a c k a g e d e . v o g e l l a . e c l i p s e . i d e . f i r s t ;p u b l i c c l a s s M y F i r s t c l a s s {

    p u b l i c s t a t i c v o i d m a i n ( s t r i n g [ ] a r g s ) {S y s t e m . o u t . p r i n t l n ( " H e l l 0 E c l i p s e ! " ) ;

    }}

    4.4. Run your project in EclipseN ow run your code. R ight click on your Java class and select Run-as ---+ Java app li ca t ion .

    www.vogella.de/art icles/Eclipse/art icle.html#updatemanager

  • 5/14/2018 Print - Eclipse IDE Tutorial

    12/39

    07103/2012 Ec li pse IDE Tu to ri al8 16 de.vogella.edipse.ide.First

    8'~src8 m de.vogella. eclipse. ide. First , : : . ,l B [lj :0~~i;~:tSi~~~:.i:~~:~t---------------------"-;1, ~wffi(?' .settings. ~ .classpath.I!i .project OpenOpen With F3

    Open Type HierarchyShow In

    F4Alt+shiFt+w

    ~Copy~ Copy QualiFied Name[t\ PasteX Delete

    Ctrl+c

    Ctrl+llDelete

    _~_Remove From ContextBuild Path

    Ctrl+Alt+shiFt+Down

    SourceReFactor

    Alt+ShiFt+SAlt+shiFt+ T

    ~Import .clExport .

    ReFerencesDeclar ationsFind Bugs

    ~J ReFreshAssign Working Sets ...

    F5

    Run AsDebug As

    F inished ! Y ou sh ould see the outp ut in th e con sole.

    MyFirstClass [Java Application] C:\Program Files\JHello Eclipse I

    I

    public class MyFirstClaspublic static void m

    5ystem.out.printl

    Alt+ShiFt+X,Alt+ShiFt+X,

    4.5. Prepare to run program outside Eclipse (create jar file)To run your Java program outside of Eclipse you need to export it as ajar file. Ajar file is th e sd is trib utio n fo rmat fo r J av a a pp lic atio ns .S elect you r pro ject, righ t click o n it a nd se lect Export.

    www.vogella.de/art icles/Eclipse/art icle.html#updatemanager

  • 5/14/2018 Print - Eclipse IDE Tutorial

    13/39

    07103/2012 Eclipse IDE Tutorial8 ed~,;~g~ii~,~~lip; r- IIS~~;~ew ~: a m de.voqel Go Into: ff i[lJ MyFi Open in New WindowO O e \ . JRE System Open Type Hierarchy F4

    show In Alt+shift+w ~~Copy ctrl+C~ Copy Qualified Namel E i Paste ctrl+llX Delete Delete_~_Remove from Context Ctrl+Al t+Shi t t+Dewn

    Build Path ~Source Alt+shift+s ~Refactor Alt+shift+ T ~

    ~Import",~Export",

    S elect JA R file, select nex t. S elect your project and m ain ta in the export destination and a nam e fornamed ilmyprogram. jar.

    r ~ bq;mft ["J~~lSelectExpor t resources into a JAR f ile on the local f ile system, ~Select an export destination:I type f ilter text I~(6 Java El: 0 JAR file

    ~:. .. ..~ J ev ad oc; ! . . . : o Runnable JAR file

    $.(6 Plug-in Development$(6 Run/Debugffi(?' Tasks B

    tIl < Back LNext > J Finish [ Cancel I]

    www.vogella.de/articles/Eclipse/article.html#updatemanager

  • 5/14/2018 Print - Eclipse IDE Tutorial

    14/39

    07103/2012 Eclipse IDE Tutorial;: JA R b ::pu [t. G J U C J ~JAR File Specification ~UeFine which resources should be expor ted into the JAR.Select the resources to export:~.. .~t?\ rde.vogella.eclipse.ide.First I ~ [!]. classpath~'D~ de. vogella. emF.webpage ~ [!] .project~'D~ de. vogella. emF.webpage. edit 8f i . .nt? \ de. vogella. emF.webpage. editor~ Expor t generated c lass Filesand resourcesDExport all output Folders For checked projectsDExport Java source Filesand resourcesDExport ref actor ings For checked projects. Select ref actor inqs ...Select the export destination:JAR File: I c:\temp\myprogram.jar B[Browse ... IOptions:~ Compress the contents of the JAR FileDAdd directory entriesDOverwrite existing Fileswithout warning

    [ < Back I I Next> ] [ Finish_ _ _ _ l ] [ Cancel ]Press finish. This creates a jar file in your selected output directory.4.6. Run your program outside EclipseOpen a command shell, e.g. under Microsoft Windows select Start ---+ Run and type cmd and pressopen a console.Switch to your output directory, by typing cd path. For example if your jar is located in c : \ tempc: \temp.To run this program you need to include the jar file in your classpath. The classpath definesare available to the Java runtime. You can add ajar file to the class path with the -j ar option.

    j av a - cl as sp at h m yp ro gr am .j ar d e. vo g el la .e cl ip se .i de .f ir st .M yF ir st Cl a ss

    If you type the command from above and are in the correct directory you should see the "Hello Eclipconsole.C:'tenp)java -classpath nyppogpan.jap de.vogella.eclipse.ide.fipst.MyFipstClassHello Eclipse!

    Congratulations! You created your first Java project, a package, a Java class and you ran this progoutside Eclipse.

    5. Content Assist, Quick Fix and Class Navigation5.1. Content assist

    www.vogella.de/articles/Eclipse/article.html#updatemanager

  • 5/14/2018 Print - Eclipse IDE Tutorial

    15/39

    07103/2012 Eclipse IDE TutorialThe content assistant allows you to get input help in an editor. It can be invoked by pressing CTRL+For example type syso in the editor of a Java source file and then press CTRL+Space. This will rSystem.out.println("").

    If you have a reference to an object, for example the object person of the type Person and needmethods, type person. and press CTRL+Space.

    package testing;

    public class Main

    e , I""" @param args" I

    public static void rnain(String[] args)Person person = new Person();person.getFirstNarne() ;~. a equa ls( Object ob i) : boo lean - Object

    I ge tClass() : C lass - ObjectI;) getFirstName() : Str ing - PersonI;) getLastNameO : Str ing - PersonI hashCodeO : int - Object9 notiFy() : void - Object8 notiFyAIiO : void - Object

    . . . ._" equals

    ;E . public: boolean equal.s (Obiec:t obj)

    Ind icates whether some other ob ject is"equa- to" this one,The equals method implements anequivalence relation on non-null objectreFerences:

    '" setFirstName(String FirstName) : vold- PersonG setLastName(String lastNamej : void - PersonB

    1 1 < I ~III 1 1 1 > 1 'L Pre" 'Ctri+Spscs ' to ,how Tsmplsta Propo,.li ] Pre" 'Tab' from proposal tabl. or clickfor foe

    5.2. Quick FixWhenever Eclipse detects a problem, it will underline the problematic text in the editor. Select thepress CTRL +1 to see proposals how to solve this problem.For example typemyBoolean = true; If myBoolean is not yet defined, Eclipse will highlight itthe variable and press CTRL +1, Eclipse will suggest creating a field or local variable.

    package de.vogeJlla_eclipse_ide.firsit;publi,c class I"lainliesit f

    /*** @pall"'am args*/,~ public stati,c void main(Sittring[] args) {

    ~=tII"'Ue;} Ia myHoool'ea 11 c:annot he rre,olvedl to-al vaJia hl'e

    < I quic k fixes avai I lahl~e:e o Crreate Ibc adlva rriabl'e 'myBoorealnl '" Crreate fie ldl 'myBool lean'@ I Crreate parameterr 'myBool'ealnl'X Remove a,ssignment

    }

    Quick Fix is extremely powerful. It allows you to create new local variables and fields as well as newnew classes. I can put try-catch statements around your exceptions. It can assign a statement to amore.

    www.vogella.de/articles/Eclipse/article.html#updatemanager

  • 5/14/2018 Print - Eclipse IDE Tutorial

    16/39

    07103/2012 Eclipse IDE Tutorial6. Opening a classYou can n aviga te be tw ee n the c lasse s in your pro je ct via the "Package Explore r" View.In addit ion you can ope n an y class v ia posit ion in g the cursor on the c lass in an ed itor an d pre ssin gyou can pre ss CTRL +Sh ift+ T . Th is w ill show a dia log in w h ich you can e n te r the c lass n ame to ope n

    - = Open Type]

    o M:yFirst tCla i~' - d!e .vogeUla .ec l ii~se. . ide. f i rs t

    f B d!e.,vogel l l 'a".eel ipse . ide . fi rs t - de . ,vog :e l l a , .ec li pse , i :de . . fi lr rs t /sse

    1...-__ o _ K _ ~ 1 [ Cancel l

    7. Generating codeEc lipse has se ve ra l possib ilit ie s to ge ne ra te code for you. Th is can save sign ifican t t im e durin g deFor e xample Ec lipse can ove rride me thods from supe rc lasse s an d ge ne ra te the toString () ,haequals () methods . It can a lso ge ne ra te ge tte r an d se tte r me thods for a ttribu te s of your Java clasYou can fin d the se option s in the Source me nu.

    www.vogella.de/articles/Eclipse/article.html#updatemanager

  • 5/14/2018 Print - Eclipse IDE Tutorial

    17/39

    07103/2012 Eclipse IDE Tutorialliioure e Re faC ior !i::: lavlga l:e S~F< :h ,~ro je ct :W in dow fie lp

    TO!lyleCDmmeml Ctrll..1Add &Iod: Comment Ctr l+Shlf t+/RerlllO'.'eBlbckCommen t Ctrl+Shiftt+\G en erat e [[ 'e m en 'll C o m m err! AII:+Shift...

    To test the source generation, create the following class in your de. vogella. eclipse. ide. f

    SliliftRi~htShift left

    CMIi-]Ctrl+Shift:_,_F

    Add ImportOr'~imi2)E:]mporhSo,r it Mem bers . ""

    Ctrl+hift+MGbi+~"Ihift+O

    Cl'ean Up ,Ov e rr id E / lmF l l emEn t Met f l lod i" .G e ne ra te G e tt er s a nd S l': ti ern ." "G],eneraDE, DeIEg:at~ M E l: ho M ....l]~nl!lat~ toce :on$ ' l r~c to '~ u~ i ng t : i ~d~" ,(l,e,nel~te ConSlr!lcto If5 'h o rn SWiperdass,, ,SIlJrreu nd W .i lh

    Select Source --+ Generate Constructor from Fields, mark both fields and press "Ok".

    MEf1l!a l iz e S tr in gs . ..F ind B,rolien hlemaliz . ef lS . t r ings

    p ac ka ge d e. vo ge ll a. e cl ip se .i de .f ir st ;public class Person {private string firstName;private String lastName;}

    www.vogella.de/articles/Eclipse/article.html#updatemanager

  • 5/14/2018 Print - Eclipse IDE Tutorial

    18/39

    07103/2012 Eclipse IDE Tutorial~ Generate Constructor using Fi,elds

    , . ]S el 'e c t : su pe r C on struc tor to in vok e:[ Objec . tOSel~e( t fields to initia I li"e:

    I

    Select Source - Generate Getter and Setter, select again both your fields and press the "Ok" butt

    ~" fir~ trN 'am e~" l'a,strN alm e

    Select Alii

    Select Source - Generate toStringO, mark again both fields and press "Ok".

    D ' e se l 'e c .t A l iiUp

    IInsertion point:[ A ft er ' s e tL a ,s tN i a n ne (S tl i n gl l'Ac c e~s modifier@ ~uhl'ic o protected 0default 0privateID Genesate constructor commentsID Om i t cal l t o' d e fa ul t constru ctor sUI~'eIO1~ e form alt o f t~ e c onstruc tors m a,y he confi gUled l 0'11 th e C od 'e 1 e m pl'a ,te sp le fe le ll c e p 'ag e"ii 2 o ff 2 selected

    ~ o _ K ~l~[ C_a_ ' I l_ce_I_ ~

    You created the following class:

    p a ck a ge d e .v o ge l la . ec l ip se . id e .f i rs t ;public class Person {private string firstName;private string lastName;

    public person(string firstName, string lastName) {superO;th is .fi rs tN ame = f ir st Nam e;this.lastName = lastName;}public string getFirstName() {r et urn f ir st Nam e;}public void setFirstName(string firstName) {

    th is .fi rs tN ame = f ir st Nam e;}public String getLastName() {r et urn l as tN ame ;}public void setLastName(string lastName) {this.lastName = lastName;}@Overridepublic String toString() {retu rn "person [fi rstsame-" + fi rstName +" lastName=" + lastName

    + " ] 1 1 ;www.vogella.de/articles/Eclipse/article.html#updatemanager

  • 5/14/2018 Print - Eclipse IDE Tutorial

    19/39

    07103/2012}

    }

    Eclipse IDE Tutorial

    8. RefactoringRefactoring is the process of restructuring the code without changing his behavior. For example reclass or method is a refactoring activity.Eclipse supports simple refactoring activities, for example renaming or moving. For example you cclass, right click on it and select Refactor ~ Rename to rename your class or method. Eclipse willcalls in your Workspace to your your class or method wiIIalso be renamed.The following shows a screens hot for calling the "Rename" refactoring on a class.

    p a ck a ge d e .v o ge I Jl a .e cJ l ip s e. i de . fJ i. l rs t jpublic class .M y I 1 l IJ ' nd lo Re~a .me l ype

    p ub li ,c s ta 't 'System. (

    }}

    C1trl l+ZR e v e rt F ileSave o-r-s

    F3F 4

    o ~e~ [ l' e c l ! aJa t[ o~Open lype Hierarchyo pen Ca JI !H ie~,aJdhyShow i n ~ lI e adl cJ Il Jm ! !,

    Ct~1+A li t+!HIAlhShi1Tt t+B

    Ct~I+OCtrl l+T

    Chl+ lA lt+ Sh iftt+ S ~~~===-------------A lh S hi 1T tt + T ~-~

    p ac ka ge d e. vo ge ll a. ec li ps e. id e. fi rs t;

    Ql lJidl ; Ow, l t1~~eQllJid< Type !Hi:er,aJchyO pe n W it l!Show In Alt+Shift+ W ~CutCopyCopy QwaJ 'i fi e d i 'o J 'ameIfl ' ,a,~te

    Ctr l+XCtrl+CC1trl l+V

    Rena .me . .. .M o ve . .. ..E x t~ , a, c t n te r ra c e . . "Ex t~ , ad Supe r d a i~ '" ,, ,l IJ '~ eS l! Jl pe r typ e Whe r e Poss ib le .PllJl l l l IJ'p. . .PIlJ.shDOWIl" ....

    For the next examples change the code of "MyFirstClass.java" to the following.

    Ql lJidl ; lF ixSourceRefado~lLocaJIH'i;storyReferences

    ~ A d'dl t o Sllil~~e tS ...

    [ l 'e!!uglAsVaJida, te

    public class MyFirstclass {public static void main(string[] args) {s ys te m. o ut . p ri n tl n ( "H el l 0 E cl ipse! ") ;

    int sum = 0;www.vogella.de/articles/Eclipse/article.html#updatemanager

  • 5/14/2018 Print - Eclipse IDE Tutorial

    20/39

    07103/2012 Eclipse IDE Tutorialfor (i nt i = 0; i

  • 5/14/2018 Print - Eclipse IDE Tutorial

    21/39

    07103/2012 Eclipse IDE TutorialYou can also extract strings and create constants from them. Mark for this example "Hello Eclipse!"and select Refactor -+ Extract Constant. Name your new constant" HELLO".

    package de.vogella.eclipse.ide.firsil:;publi.c class I"1yFirsil:Class {

    02' publi.c stati.c v'Did main (Stlring[] ar-gs) {System. out. pr-i.rrt In ( ) _;i.llt s .urn = ,e,;su m = cat c!JLateSf;', ""'=~""=="'==~~~"""'iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii iiiiiiiiiii~~~=r-~r-;::::;rF~System ..out. pr-i.nt; ~ ~ ~ E : . : : ) { I j : . ; r a : c : . : . . tC : : : : o . n ~ ~ : : t a ~ n ; " t===============!!==~:::::~=

    }

    }!:oollstant name: t lHELILO

    plt"i.vate stati.c illt cfot" {i.nt i = e;

    sum -iI-= J L ;Access modifier: e J puhl'ic 0protected 0default ~ p'~i,yate~ B,epI1a.ceadllcCI!mences of the selected expression wit~ ~cle~ellces to. the con1 0 Q I! J ad'ifyconstant referen ces witlh typ'e IIarne

    }

    P~evi~ 1 [ . . . ~~O_K~---'] [ CanIfllOhl'ems

    The resulting class should look like the following.

    package de.vogella.eclipse.ide.first;public class MyFirstclass {

    private static final String HELLO = "Hello Eclipse!";public static void main(string[] args) {

    system.out.println(HELLo);int sum = 0;s um = c al cu la te su m( su m) ;system.out.println(sum);}private static int calculateSum(int sum) {for (int i = 0; i

  • 5/14/2018 Print - Eclipse IDE Tutorial

    22/39

    07103/201210.1. Adding a library (.jar) to your project

    Ec li pse IDE Tu to ri al

    The follow ing describes how to add Java libraries to your project. Java libraries are d istributed v iaassum es that you have a jar file available; if not feel free to skip this step.Create a new Java project de. vogella. eclipse. ide. jars. Then , create a new folder calleclicking on your p roject and selectin g N ew --+ F older.

    II. . 1 ; ; - 6 d'e.vogell 'a"eclil~,se. id'e. jlar.I> ~ srcI> e\ J RE S y-s te m lL ih ran y IJ

    N ew ~ r J a . v . a l ~mje c t- & AndllOidl Projectrj IPmjec . t . . .. ..F4 8 : i ' Ifl'ac lGa.ge

    Alt+Sllift+ 'W ~ $' ClassOpen in N ew W indowOpen lype HierarchySllowln

    Ctrll+C a InterfaceG ' Enum@ f Annotation$3 Source Follder.'Ij J a M a l 'W o d :: in g S e t[j Folder

    ~ Copy~ Copy Qualifie d rN lam eIi Pa.steX Del'ete

    Ct~I+.vDel'ete

    _ , > . Re m ave from C on te xt C trl +A lt + S h ift- Down

    From the m enu select File --+ Im port --+ G eneral--+ File S ystem . S elect your jar and select the foldeA ltem atively, just copy a nd paste your jar file in to t he " lib " fo ld er.R ight click on your project and select Properties. U nder Java B uild P ath --+ Libraries select the butThe follow ing exam ple show s how the result would look like, if the jun it-4 .4 .jar had been added to th

    ~ Properties for JUnitT estJava Build Patht yp e f ilt e r t e xt

    :....Resource!"'BuildersL . . . Ja va Bu ild Pa th$ J av a C od e S ty lem Java Comp il e r~ Ja va E ditor:....J a va doc Lo ca boni . . P ro je c t R e f e re n c e si . . RunJDebug Se t bng si . .Task Repos i toryi . . Task TagsL . . . Validabon

    ~ Source Ie Proje cts ~ L ibra rie s I { l o \ i > O rd e r a n d E xp ort IJ ARs a n d c la ss f o ld e rs o n t he b uild p at h:~ D jLJtlit~~:~J< lr~~~tlit !~~Y1i~ j A dd JARs.. .i! J e\ JRES y st em L ib ra ry D re 1.6.0_02J

    Add Var iab le ..A dd L ib ra ry . ..

    OK Canc

    www.vogella.de/art icles/Eclipse/art icle.html#updatemanager

  • 5/14/2018 Print - Eclipse IDE Tutorial

    23/39

    07103/2012 Eclipse IDE TutorialAfterwards you can use the classes contained in the jar file in your Java source code.10.2. Show source code for jarAs said earlier you can open any class via positioning the cursor on the class in an editor and presAltematively, you can press CTRL +Shift+ T. This will show a dialog in which you can enter the classIf the source code is not available when you attempt to open a class, the editor will show the decomof that class.This happens if you open a class from ajar file and the source for this jar is not available.To browse the source of a type contained in a library (i.e . . jar file), you can attach a source archivethat library. Afterwards the editor will show the source instead of the byte-code.Inaddition setting the source attachment allows debugging this source code.The Source Attachment dialog can be reached in the Java Build Path page of a project. To open thclick on a project ---+ Properties ---+ Java Build Path. On the "Libraries" tab, expand the library's nod"Source attachment" attribute and press Edit.Inthe Location path field, enter the path of an archive or a folder containing the source.The following shows this for the standard Java library. If you have the Java Development Kit (JDK)should find the source in the JDK installation folder. The file is typically called "src.zip".

    I type f il te r text~ Properties for Documenta.tion ~ L Q ] L R l

    , Resource, BeanInfo Path

    lBJava Code Stylei I . . Java Compiler$..ava Editor,....Javadoc Location:....Profile Compliance and Validatic> . Project References(. Refacto r ing History: Run/Debug Set tingsL SVNInfoL Task Tags: Val idation

    Java B.uildPath

    JARs and cless folders on the bui ld path:

    Ifij ant.jar C:\Documents and Settings\D034797\Des LA~~.;,;' ~El~ JRE System Library [jrel.6.0_Ol] -- - -- 1: ~ Acce55 rules: No rules defined I Add External JARs...! ~ Native l ibrary location: (None). Add Variabre.. . II i . . .~ resources. jar - C:\Program Files\Java\jrel.6.0 _a;i i rt.jar - C:\Program Files\Java\jre1.6.0_0l\lib I Add Library... JL:i Javadoclocation: http://java.sun.com/jav Add Class FO~i z i . l ' Native l ibrary location : (None), L . . . . ~ Access rules: (No restr ictions) - non rnodft "---------------~.ii1 isse.ier - C:\Program Files\Java\jrel .6.0_Ol \Ii lIi!.~ jce.jar - C:\Program Files\Java\jrel .6.0_Ol \IibI i! ~ charsets. jar - C:\Progr am Files\Java\jre 1.6. 0_~ ~ dnsns. jsr - C:\Program Files\Java\ jre1.6.0_0l LMigrate JAR File..~~li!i:1localedata.jar - C:\Program Files\Java\jrel.6.[1 i ! M l QTJava.zip - C:\Program Files\Java\jrel.6.0_[1 l . . .!i1 sunjce _provider. jar - C:\Progr am Files\Java\jn~ .., sunmscapi.jar - C:\Program Files\Java\jrel .6.[ffi1il sunpkcsl1.jar C:\Program Files\Java\jre1.6.(

    Edit ...Remove

    > 1

    r O K ~ l [ Cancel10.3. Add the Javadoc for a jar

    www.vogella.de/articles/Eclipse/article.html#updatemanager

    http://java.sun.com/javhttp://java.sun.com/jav
  • 5/14/2018 Print - Eclipse IDE Tutorial

    24/39

    07103/2012 Eclipse IDE TutorialIt is also possible to add Javadoc to a library which you use.Download the Javadoc of the jar and put it somewhere in your filesystem.Open the Java Build Path page of a project via Right click on a project --+ Properties --+ Java Build"Libraries" tab expand the library's node, select the "Javadoc location" attribute and press Edit.Enter the location to the file which contains the Javadoc.

    ~ P rope rtie s fo~ de.voqella.docsI type f i l i te ! t e xt

    Res;olllJll'CeBllJiilldelsGoogleJava 8 1 l J i I !d ~ ,a ,thJava Code Sty IeJava CompilerJava EditorIavad 0( iLo.ca t i onJHSettirn.g.s1P'1' llJig-illJ'evelbpmerI P'm j ec .t R eff e! e~ c esRefacto!i IIgl His to ryR I ! Jn /Debu gl S e t t i ng,sTask lRepolsitoonyT a sk T a qsV.alida.tionWill:illext

    ~ I r r r I ~

    M igrate JAR

    Ja,va Build Pa,th " ' I, l2 5 ! Some e .I . 1 2 3 P lo j e c t, 1 e\ l.ibra Ii es 1 6'i} O ld 'e ! all d l E x po ort IJ IA Rs a n d l (I a" , folders on t h e b l lJ l il 'd lp , aIh :

    [> ~ (om m ons-c ode c-1 l3 ,jall - d e..v og ell!a".d bc s/lih /httl ...[> ~ w mm om .-h tt pd ie nt -3 ,1 -t l,e tal l,ja ll- d e" vog ella" d',,,[> ~ wmmom .- lo gg in gl -l lJ [, Ja r - d 'e ,v og eU 'a ", do c> !l li l: >! 1rt> ~ wmmon !.-I og gi ng l- ,a ,d !a pt ere s- ], l, jl ar , . d le ,v og el ll 'a ,~t> ~ (om rnons-l O o g g ingl-,a ,pi l -l .l l . ja1- de "vog l e ll a " dio -c> !1t> ~ j cornmoa- II,f) ,6 ' ,ja,l- de"vOogellla"docs/l ih/httpc Iier.. e,. J IR E S ys te m L ii tl la lY [ jre 6]

    & I i : Ac(ess nules: Nb rules dleffiilledlit r N ia ti ve I ibra ry llocation: (Noll e)I> ~ resources.jar - C:\Prog ram lFiIes\)a,va'ljIe6\I'i b.. ~ rtjar- C :W IO gJ la m F il l' es \J la ,v al \i re 6 \1 i lt l,I T ! Source atta dh m ent: (rN bne )

    Ad d lA RA dd q te rn al

    A dd Y arialAdd L ihrg

    Ad d r i a " F ([ Add Ex ternal C ia

    ~d'it."[@ J la ,v,a ,doc Ibc.a t ion: ht tp: // d 'ownlbadl ,ma,c ie , ' """" ',i! N i a, ti ,v e l 'i hl ,a lY I bc a, ti o n: ( N o ne )& I i : A cc e9 s lu l!e s: (No lestridions)- non modi

    I> ~ j ss ej ar - C :\ P'w gl .a m l Fi le s\ )l a, va \j re 6\ 1'i h

    l ..=~~~. I > ~ ~ ~ ' ,~ji~~,e~,j~,ar~-~~~Ir:\~'~ro~g~r~am~"~IF~ille~S~~I~a,v;;;,a;;; ' \ i; ; ; ' Ie6;;; ' ; ; ; \I;; ;itl; ; ; ,;;;;;~;;;;;;~=;- - : - I~ I m J ~ I

    j&emo'V

    F" ( --a-oK - ......[ Can(ell I I11. Updates and Installation of Plugins11.1. Eclipse Update ManagerEclipse contains an Update Manager which allows you to install and update software components.software components are called features and consists of plug- ins.

    To update your Eclipse installation, select Help --+ Check for Updates. The system will search for ualready installed software components. If it f inds updated components, it will ask you to approve thTo install a new functionality, select Help --+ Install New Software

    www.vogella.de/articles/Eclipse/article.html#updatemanager

  • 5/14/2018 Print - Eclipse IDE Tutorial

    25/39

    07103/2012 Eclipse IDE Tutorial~ Install

    l Fin d l m o re so ft wa re h y w or li :i n gl w ~ 1t hth e " Av a i Ja ,h ll e S oflt wa ~ e S ite s" p re te re nc es ,Ityp e fi I te ~ t ex tNamn e Ve~.s'ion

    ID D D D A pp lic ation [le ve lop me ~t F ~a me wo~ li:sID D D D B u si n e ss I ~t el li rg le n c e , R e po rt in g and Charti 1 1 9 1ID D D D CDIII 'abo~a,t ionID D D D D ata ba se D e ve l'o pm e ntID D D D E e l i l ~: seRT T a l~ g e t P l ' at rl To rm Comp on e nt s

    ~ L J~e le c t A ll II Q ese le c t A ll I

    ~ Show only tlh e late st veas iom o1Ta,vaila ! I , Ie so1T1twaJe ID H i d ie i ,t em , ~ t h a ta re a I I~ ea .d :yi nst a l le d~ _WIlJP i t em , hy c a.teg :D ry W lha.t j ,s all~eady installed?ID Show on ly sO oftw a,~ e a pplicable to taJge t e nvironrn e llI t~ i:onEad all liJ pd ate sjte s d m i ng rlllt> itadilo . 1T i1 dl req,wJr~edlsDftw,a,~e

    L -_< -=ft : .. ._ ac _k_ -, L_= t :J .: .. ._ e J r t_ ,> _-,I L I_-= E_in_i,_ h_ -,I L I_ _ C _a~ _.c_ e" _J

    From the "Work with" list, select an URL from which you would like to install.To add a new update site, press "Add" and enter the new URL as well as a name for the new updaSometimes you have to uncheck "Group items by category" _ not all available plug-ins are categorinot categorized, they will not be displayed unless the grouping is disabled.11.2. Manual installation of plug-ins (dropins folder)If you're using a plug-in for which no Update Site is available, you can use the "dropins" folder in yoinstallation directory.Plug-ins are typically distributed as .jar files. To add a plug-in to your Eclipse installation, put the plthe Eclipse "dropins" folder and restart Eclipse. Eclipse should detect the new plug-in and install it11.3. Eclipse MarketplaceEclipse also contains a client which allows install ing software components from the Eclipse Marketadvantage of this client is that you can search for components, discover popular extensions and seand ratings.Compared to the update manager you don't have to know the URL for the update site.

    www.vogella.de/articles/Eclipse/article.html#updatemanager

  • 5/14/2018 Print - Eclipse IDE Tutorial

    26/39

    07103/2012 Eclipse IDE TutorialTo open the Eclipse Marketplace select Help ~ Eclipse Marketplace.~ IEci li p- ;; eMa r ke l p~ la c eElclip.5e Mai~~etpla;ceS el~ e c.t s ol ut io ns to i ns ta ll . l P'~ e~ s lF i us h t o ~1I0Ce e d w ii th i ns ta ll a .t iio n.P '~ es~ th e in form a ,t i on h UJtto~ to se e a , de ta ~ I~ ed lv erv ie w a n dl a, I 'i 'n l(tom m e inf'orm altion .

    . . . 1 1 AI'IICaltegoriesWlindow.s Azure Teols f,Dr Ec:lipse - PHiPThe purpose off th ii, p w j e cf ii~th e c re ati O onof , alf ea tu re - ~ ii ch o pe n SOIU r c e I P'I HP.al~ pliication dle ve lbpm e nt e rw ironm ent in E clipse that e nable s d le ve lbpm ent .andl. ....hy Soyate c; A pa ch e 2Jl [ Insta IIII -IP H lI PC lb lU d C om p lU ti nQ lW in do ws A lm e

    A s p a. rr tt of fM ' iCW o so tt &Ht l3 g, ;s c omm i t m e nt t O ol ~t e wp e ~.a hi Ti ty . this op en sourc ep ro je ct is .a n e ffi Oo rt ori dg ie J la .v .a ld ev el op er s t o' W in d o w, A zu re , 1 Il h, ii~s ,aimope~soulJce "''''h y S oy a te c , Oth er~ W i~dow s A lm e

    W,indowTester Pr,D,Gl.!I[TesterW in d o ow1 1e st e~ ~ r o is n ow O off ie ~ ed ls ,a lfr ee d lo wn lb a.d l b y G O oO gle, IP ' l lea,s es ta.y tunedlf fo ~ e x c iting new annolU nc e rne n ts c om ii~g ,soon on the Goog leW eh T oolkit hl~o9l. .hy GOOogle Inc ." C ornm e sc ial - IF re e Le arn m oreI ~ s ta n ti ;a ,ti o~ s G lU I T e st i n 91 S 1 i V l i lU I 11es t in 91 Swing : lU ~ 1 1e s ti n g: 9 Oo oq l 'e

    \ W,indowBuil'der PrD 'GU[ De.sigllerWlndOowlB lU i lld e~~ro (S1 ; i\ ! TDe" i9 lme~ and Sw ii ~ g [ J' e si g ne r ) ha s be en d om a.te dl to' th eope n iSO UlK e c om m uni:t iy t~ rou 9 h th e E d'i p se lFoU Jdlahon. a n dl is ii~ the proce ~sof.,..

    ,--_ _ - - -> I . . . . ._ _ E_in_i_sh _ _ ,1 . . . . ._ _ C_a_n_ce_I I_- ,

    You can use the "Find" box to search for components. Pressing "Install" wil l start the installation pro

    11.4. Restart required?After an update or an installation of a new software component Eclipse to restart Eclipse. Ingenerato restart Eclipse in this situation, otherwise some components might not work corrrectly.

    LakeQuingMEDIA lMiil l ionsof dev,el~opers: one caThe wo rl'd i's le . ad in g d e ve lo pe radl. ie r t is iingl g l"Oil lP12. Efficiency Settings

    www.vogella.de/articles/Eclipse/article.html#updatemanager

  • 5/14/2018 Print - Eclipse IDE Tutorial

    27/39

    07103/201212.1. Eclipse Preferences

    Eclipse IDE Tutorial

    The behavior of the Eclipse IDE can be controlled via the Preference Settings. Select Window ~ Popen the preferences settings dialog. You can use the filter box to search for specif ic settings.12.2. Automatic placement of semicolonEclipse can make typing more efficient by placing semicolons at the correct position in your sourceInthe Preference setting select Java ~ Editor ~ Typing. Inthe section "Automatically insert at correnable the "Semicolons" checkbox.You can now type a semicolon in the middle of your code and Eclipse will position it at the end of thstatement.

    I t yp e fi l ite ~ te x tI> Gene ra lI> AndlOid lI> An tI> lHel'pI> InstadJIIU pdate.. Java

    I> Appeasan ceI> Buil d l Pa t hI> Code :s tyl'eI> CompilerI> De~liJg.. E ditor

    I> Content A9Si,stlFold'ingIHOiVel15Mal~k ccusrenc esSave Act iDnsSYl1 ta l l CO ' IIOI ing J1m pl a,tes[ lyp imgj

    I> Instal I ledlJREsJlIJ 'nilP ro pe rti es lF ile s E dit or

    I> MyliynI> 1P'1'llJlg-il1l'evelbpm entI> Rllm/De! ! l lJg lI> TeamI> l I J' sage [ l 'a t a. Co l le c t or

    ValidationI> XMIL

    TypingThe pre fe re nce > on this p ,ag e are onl:y c on sid ere d iff 'Srn art In se rt M od ie ' iiSse le cte d,

    A u .t om a ti ca ll l: y d os eI ! ' J "~t~il~gs"~ W a l~ e nt lh ,e se s} , [squase] and < : a n gl l: e > ! !~ a c! e ts~(BIa,c es )~ J a,: !t a; dO 'c an dl c om rnenf ~ eg ions

    ~ A dd !a,vadoc taqsA u.to m ati ca 1 11 :vn se rt a t correct positi onI~Semico lons I~. !2c~a;cesIndlenta,t i:on~ Ente r li:ey adjusts the indenta,t ion Oln the new line~ lab keyadjusts th e i nde nta,t iloll of t~ e cUJ ~ el lt l in el~ e ta l!!' djspl a, y va Iue (CIlJ ~ re ntl y 4 }a 11d l w he t~ e ~ s ~'a ;c e sa Je used to ' ill dent Iillles ar econf 9 ured 0'11 th e 'l Fo ~m a tt e~ ' preferenc e p a,g :e . T he C Il JI~ re nt in de nta ,ti on m ode usestabs,Wh e ll ~ 'a is ti ng J~ A dju.st jn d e rrtation~ !1 pd!ate i rn portsIn :sb i~gll~t e~all~~ W r ap ' , al lu to om a ti ca Jl yI ! ' J Escape te xt w j) e n ~ a,st~n 9 1 i li to a s tri n 9 I lite~adl

    [ R e st or e ! Q: ef aU It s I [ ~ppl:y. .. .. .. ._ _ O_K J . _ [ _ C_a~_,c_ell_ . . J

    12.3. Imports and Source code formatingEclipse can format your source code and organize your import statements automatically during a sThis is useful as the "Save" shortcut ( CTRL +S ) is easy to reach.You can find this setting under Java ~ Editor ~ Save Actions.

    www.vogella.de/articles/Eclipse/article.html#updatemanager

  • 5/14/2018 Print - Eclipse IDE Tutorial

    28/39

    07103/2012 Ec li pse IDE Tu to ri al

    I t yp e f i I lt e~ t ex t:Genera lAndlOid lAn tHelpInstadJIIU pdateJava

    Appearan ceBuild PathC od e S ty l~ eCompilerDeh lUgEdi,to 'r

    Content AssistlFolding!IHOiVel15

    ~ I

    Mal~k OccunenoSave ActionsS ym t ax C oll Oli n9 1 -1m ~ 'I a, te slyping

    I n st a I l led l J lREsJ l I J ' n i lP 'r op e rt ie s l Fi le , E d it c -e-

    m I ~

    -

    ~ I

    ] l P 'e r jj o~m t h e se l e c te dl ,ad i:ons on save~ I f .. ? . r .0 a . : ~ i ? . ~ i .' ~ .~ . ~ ? . ; ~ : ~

    @ l F o~ma t a li i l in e sIf) lFo~ma t ~d ' it ed ll~~H5Conflg!~ re th e form attes sethngi> on the IF mm atte ~ p 'age "

    ~ O ~g'ani'ze jrnportsC on fl9 lm e th e o rg la ni c.c e imports settin g ,5 o n th e O~ga n i l1 : e1mp 'o rt s p ag e "

    1 0 Ad ' d~~ iona l l ad ion sA dd final m odifie rto private fie ldsA dd m issing '@ O ye rride ' an notation sAdd rnissinq '@ Oyerric le ' annotations to im plem entations of in te rface mA dd rnissinq '@ De pre cate d' annotationsRemove unne ce ssary casts

    Im port s tatem ents w ill o nly b e au tom atically im ported, if Eclip se find s on ly o ne valid im port. If E clipsm ore then one valid im po rt, it w ill no t a dd im port statem ents autom atically.

    [ Res t or e ill~

    ~ O_K_ ._ _ j ] L[ C_a_n_ce_I I_ ~

    12.4. Filter import statementsThe "O rganize im ports" S ave Action or the ''''O rganize Im ports" shortcut ( CTRL +Shift+o allows top ackages w hich are req uired. If there are several altem atives, E clipse sugg ests all availab le packahas to select the righ t one.To follo win g sho w this selec tion for th e Li stclass.

    www.vogella.de/art icles/Eclipse/art icle.html#updatemanager

  • 5/14/2018 Print - Eclipse IDE Tutorial

    29/39

    07103/2012, : :_,i lmpo,rt:ilmpolrt:ilmpolrt:iimpolrtiLmpolrt

    Eclipse IDE Tutorial@'rg.eclipse. swtt. SWT;o-rg. eclipse. swt ,widgetts .IIHsplllay;o-rg. eclipse. s@,rg.eclipse. s@'rg.eclipse. s Choose type to import:

    ~.... Organize Imports

    pub'llic st,illtilCV.OIm a;mhsplay disPage 1 ofl

    pubHc clII.a!ssFirstS

    Shelll shelll

    java.awt.Li5t[ava.utll.Llst

    o org.edipse.swt.widgets.Listcre'ateil.li 'I disshel l ,pack (}shelll.@pen(}whill ,e 'I l s h e lif 'II disdisp}d.i.sp lay. displ < Ba c k Next>

    '5 0 en} {

    This is annoying, if you never use certain packages. You can exclude these packages via Windows--+ Java --+ Appearance --+ Type FiltersPress "Add packages" to add a specific package or "Add" to use wildcards. The following will excpackages from import.

    www.vogella.de/articles/Eclipse/article.html#updatemanager

    mailto:@,rg.eclipse.mailto:@,rg.eclipse.
  • 5/14/2018 Print - Eclipse IDE Tutorial

    30/39

    07103/2012 Eclipse IDE Tutorial

    " G ene ral" A nt" H e lp" I ns ta ll/ U pd at e'" Jav a'" AppearanceM e rrn be rs S ort O r

    Typ e F il te r sto B u ild P at hto c ode sty leto Comp i l e rto Debu~to Editorto I ns ta ll e d .! IRE s

    JunltP rope rtie s F ile s E di

    " M ylyn" p lu lQ r ir lD e v e lo pme n t" R u.n /D ebu QI

    12.5. Templates

    A ll type s w hose fuilly qualifie d nam e m atc he s the se le cte d filte r s trlnq snot be show n in the O pen T ype ' d ialog . T hey w ill also be ignored in con teassist or qu ick fix proposals and w he n organ iling im p orts . F or e xam p le'jav a.aw t.; ,' w ill h id e all ty pe s from th e aw t p ac kag es.F il te r l is t:,--~ jav a.aw L " l Add.,----------~~~~ [A dd pa(kage s

    Ed i t . ..R emov eE na ble A llD is ab le A l

    T yp e re fe re nc es w ith ac ce ss re stric tion s:~ H ide forb idde n re fe re nc eso H id e d is co ura ge d re fe re nc e s

    [ R e s to re D e fa ull ts 1 , - [_ _ A_p_ ._ l_~_ c _a_ nc_ e _I_~ ] [ ,-_ _ O _K_ ~

    If you have to frequently type the same code I part of the document, you can create templates whichvia autocomplete (Gtrl + Space).For example, lets assume you are frequently creating public void name() {}methods. Youtemplate which creates the method body for you.To create a template for this, select the menu Window ~ Preferences ~ Java ~ Editor ~ Templa

    www.vogella.de/articles/Eclipse/article.html#updatemanager

  • 5/14/2018 Print - Eclipse IDE Tutorial

    31/39

    07103/2012 Ec li pse IDE Tu to r ia l. -~ Preferences bJl~JI type Fil ter text I Templates T .-'\ " '"~WGeneral A$ Ant ~ ~reate, edit or remove templates:IE " Data Management Name 1 Context 1 Description 1 AutoIn.~ [ t iew ...$ Help ~ @author Javadoc author name on " [" InstalliUpdate ~ Javadoc on !;_dit..8"Java ~ Javadoc on [$" Appearance ~ Javadoc on 8,emove

    $" Bu ild Path ~ Javadoc onIE " Code Style ~ eddhs te ... SWT statements add a l istener to a ... [ Restore Removed$"Compiler ~ arrayadd Java statements add an element to ... [ Re'Lert to DeFault$"Debug ~ arraym ... Java statements merge two arrays i . ..- ~ Browser SWT statements new Browser8"Editor ~ Button SWT statements new Button I~::Content Assist Import ...~ cast Java statements dynamic castFolding ~ catch Java catch block I E!]JOrt ...overs ~ Combo SWT statements new Combo

    ::..Mark Occurrences r;:;;l'.-.mn.-..::il-,::. c;~.'.n .::I-.::.I-,::.m,::.nh:: n,::....... limnli.:::ih= ..... lil- 8Save Actions < I 1 1 1 1 1 1 0

    ""Syntax Coloring Previe\:t_:: : : i;~~~~~~"j ~" FindBugs -

    ~" Insta lled JREs: "JUnit.., Properties Files Editor

    Java EE ~" Plug-in Development .iJ$Pydev ~ Use code [orrna t t e r$" Report Design B.- . n.,... r- , . . . .-....... [Restore Q.eFults 1 [ WplyI ~

  • 5/14/2018 Print - Eclipse IDE Tutorial

    32/39

    07103/201212.6. Code Templates

    E clip se ID E T uto ria l

    Eclipse generates lots of source code automatically. For example, in several cases comments aresource code.Select Window ---+ Preferences ---+ Java ---+ Code Style ---+ Code Templates to change the code gentemplates.Inthe code tree you have the templates. Select for example Code ---+ Method Body and press "Edittemplate and to remove the "todo" comment.

    I typ e fi lter textGenera]And '~o :idA ntHelp ,Install/Upd ateJ i a r v , a l

    A~pearance81lJiid ~,a,thCode Style

    Clean UpCode T e m p la te s ..~oli"ma[ltterO ~ g a n i z e Im p ort

    CompilerDebUg!Ed ' i tOi

    Content A:~,i istFolldi l lglHover ,Mia. r i l :OC( urren 0~Save Actions

    ~ I

    Syntae< Colb~i~glTemplatesTyping!

    Imta,U'ed l J REsIllnit~mpe r1 ii e , l Fi ll e sEd it c . ..

    m I ~

    Code TemplatesCOllfigul~e iP'wje

    &;onfi g.u~ e ge ne rate dl (ode and c om m e rn ,ifs :C omm en t sCod 'e

    New Java filesClass tmdyInterfac e bodyEnw lm bodyAllulotatioll oodyMet hod oodyConstructor hodyGet tel l tmdy:Se t t e~oody

    1/ $ {t od o} A ut o- ge ne ra te d m et ho d s tu b ~ f : : ; ! de, ivog:el l a.edipse.i d e. , f f i i~ :s tt> ID f : : ; ! de. ivog:el l a.edipse.i d e.ja ~s

    ID LJ de. ivog:el l a.edipsedemocam p .and ro [d l. d l~ ,awID LJ de. ivog:el l a.edipsem a.g l .W,arVe1 0 LJ de. ivog:el l a l . ,emrf f .i l l lh.e~itanc eID LJ de.,vog:el lal . ,emrff.wuidlID LJ de"vog:el la l . ,emrTI .webpa,ge.model l

    o

    Se l~ ed A l l 1 I D e se le ct A ll

    ' - - - -_ _ _ -, l 1 1 . . . . . . _ _ Fi_ln_ir,_fl___ . ] L I _ _ C_ a_l l l_c_:e_1-'

    ~ Select W orkin g Se tS e l~ e ( t , a lw o rl (i n g : s e t :iE l W illd ow W od ~in g: S etso Nb Wo~lk in g S e ts@ I S e le ( te d ] Wm lk in g : S e ts

    ~ l i b My l Fir st l ar va I Pr e je c t s N 'e w . ..Ed it . . .

    Remove

    S e l e c t A lii I I [ }ese l !ec t A l ii I~ o _ K ~lI _ _ C _ ' a _ I l _ , (_e_II_-,

    You can now easily display only the files you want to see.

    www.vogella.de/articles/Eclipse/article.html#updatemanager

  • 5/14/2018 Print - Eclipse IDE Tutorial

    36/39

    07103/2012 Ec lip se I DE T ut or ia l~ l? ac lC ag e IE xp l'm e ~ n~ t: l yp e l H'i e~ a~ dl Yl = E l

    I B []I ~ "VII I MyFii~stClla,ssja,,,,,al n~

    public class. . ~ d e "v o ge l l! a' .e d ip .s e .i id e .. fi ~s t

    . . i lf ' src. . & : ! d e . .vogell!a,.edi p s e .i d e . fi rs tt> J lI M a.in l e s t -j a v. alt> [ I l l Mylt i ~s tC l 'ass .j la,v.a l lt> II I P"ersO'~ .java

    t> E A J IRESystem l.ibra ny [jre71

    TOI l?Leve l EI ' emenESSe l e c t W Q1~k ingSe t . . . .Deselect Wod::ingJ SetEd it Ac : ti ,Y eWO ' ~k i~ g Se t . . . .

    ~ ] W in dbw WO lk~~gISe t--- ---lb 2 . My l Fir st J :a ,y a, ~ rejects13. Eclipse Help and Community13.1. Eclipse BugsEclipse has a public bug tracker based on Bugzilla. This bugtracker can be found underhttps:/Ibugs.eclipse.org/bugs/. Here you can search for existing bugs and review them.To participate actively in the Eclipse bugtracker you need to create a new account. This can be do"Open a New Account" link.". . ~~!ClipSe i~ -, ~.'- ~ BUGSBugima - Nain PageHome I New I Sean-dl' I I I I [Find 1 I Re~)O"ts. I RequestsI New AccolJnt I Log.nn I Fmglot Pa:ss.wmdl I Terms 011Use I Copyri:ght Agent

    'kl ..He i

  • 5/14/2018 Print - Eclipse IDE Tutorial

    37/39

    07103/2012 Eclipse IDE TutorialThe Eclipse help system is available from within your Eclipse installation as well as online.With your running Eclipse IDE you can access the online help via Help ---+ Help Contents. This will swhich shows you the help topics for your currently installed components.

    5 .e arc i1 : '----- -' a m S c o~ e : A i ll op i cs~ Help -lEclipseCon te rn ~ ... I 7 & . . . I B ~ n iiii""":;..... "T= : ; ; ; ;: : := . . .. . .. . ~ " ' "

    lB. Workben1d~ I !J 'ser Gu' idelB. f f i l l v . l I develolpmeifJt IMJ.ser'9uidelB. P l at fo rm P l ug -i nl D e 1 J 1 e li op e r(lB. P lu :g - in l ~ e " ,e ~ i o p;men t IEmv ] rorlB. Eclipse M ark etp lac e U se r GUJi,lB. EGit nocumenrttafiolllJIB ., EMFDe.ve,1'opefGlI]id'eIB., Myly ' l l Documentatio:nIB R AP' D e ve lo pe r 'E iu i[d eIB Usage I I D i ' l f t a l Colll~edorlB. XP,1I thz .o li'IrOCe.5Sm U se r I M a.lB. XSt 11001:5~ser Documentaflc

    Selilrc'hing

    Using the help systelllBrowS'E!lopics in ~meContents frame (I)i Onl ~tJeIleft Click oml aJ topic I IIIIIave it displa.yed. Use~lIe lBilJc'kand IForward buttons to naviigale withiilFiltheIl listmy of viewed topics.

    To qu iekly lecate topics 0n a pBlrticu'I'ar.s~,bject ln the do cumerrtatio m i. enter aquery iin the Search fleldl_ Use the Search firatlille (W ) 1 .0 display I ile Searchv~e~)I.You can naif01N tile scope o ff yo~ r s e a rc h by selleclingl o nly Ih esections you ars in!er,ested in_SynchroniizingClicking tll,eShollV in Table of Contents button {~) wT11select thaI topic inblie naviga.fion tree'_Tile Link wit!], Contents button (10) [:;,eeps~lIeIrrl

  • 5/14/2018 Print - Eclipse IDE Tutorial

    38/39

    07103/2012 Eclipse IDE Tutorialto give a good error description as this motivates people to give you high quality answers.13.4. WebresourcesThe Eclipse homepage also contains a list of relevant resources about Eclipse and Eclipse prograthese resources under http://www.eclipse.org/resources/.Also the author of this description maintains several Eclipse relevant tutorials on his webpage. YouEclipse related articles on http://www.vogella.de/eclipse.html.

    14. Next stepsTo learn how to debug Eclipse Java programs you can use Eclipse DebuggingTo learn Java Web development you can use with Servlet and JSP development. If you want to dealone Java clients you can use Eclipse RCP You can extend Eclipse with Eclipse Plug-ins.Good luck in your journey of learning Java!

    15. Thank youPlease help me to support this article:

    16. Questions and DiscussionBefore posting questions, please see the vogella FAQ. If you have questions or find an error in thisthe www.vogella.de Google Group. I have created a short list how to create good Questions whichyou.

    17. Links and Literature17.1. Source CodeSource Code of Examples

    17.2. Eclipse ResourcesEclipse.org Homepage17.3. vogella ResourcesEclipse RCP Training (German) Eclipse RCP Training with Lars VogelAndroid Tutorial Introduction to Android ProgrammingGWT Tutorial Program in Java and compile to JavaScript and HTML

    www.vogella.de/articles/Eclipse/article.html#updatemanager

    http://www.eclipse.org/resources/http://www.vogella.de/eclipse.html.http://www.vogella.de/http://www.vogella.de/http://www.vogella.de/eclipse.html.http://www.eclipse.org/resources/
  • 5/14/2018 Print - Eclipse IDE Tutorial

    39/39

    07103/2012 Eclipse IDE TutorialEclipse RCP Tutorial Create native applications in JavaJUnit Tutorial Test your applicationGit Tutorial Put everything you have under distributed version control system

    www.vogella.de/articles/Eclipse/article.html#updatemanager