Using Eclipse Europa - A Tutorial

Similar documents
PART 1. Eclipse IDE Tutorial. 1. What is Eclipse? Eclipse Java IDE

Index. Symbols. /**, symbol, 73 >> symbol, 21

Just Enough Eclipse What is Eclipse(TM)? Why is it important? What is this tutorial about?

Using Eclipse for Java. Using Eclipse for Java 1 / 1

S8352: Java From the Very Beginning Part I - Exercises

In this Tutorial we present tips and trick for the development enviroment eclipse and the extension MyEclipse.

Noopur Gupta Eclipse JDT/UI Committer IBM India

An Introduction to Eclipse: Quick Guide. Part 1: Getting Started with Eclipse Part 2: Working with Eclipse Useful Online Guides

At the shell prompt, enter idlde

This cheat sheet is aimed at people with some experience in eclipse but who may not be aware of many of its features.

GETTING STARTED WITH ECLIPSE Caitrin Armstrong

COMP 110/401 APPENDIX: INSTALLING AND USING ECLIPSE. Instructor: Prasun Dewan (FB 150,

NetBeans IDE Java Quick Start Tutorial

CSCI 161: Introduction to Programming I Lab 1b: Hello, World (Eclipse, Java)

Getting Started with Eclipse for Java

Getting Started with Eclipse for Java

Eclipse Tips and Tricks (JDT)

Javac and Eclipse tutorial

Module 3: Working with C/C++

1. Go to the URL Click on JDK download option

CS 201 Software Development Methods Spring Tutorial #1. Eclipse

Creating a new CDC policy using the Database Administration Console

WPS Workbench. user guide. "To help guide you through using the WPS user interface (Workbench) to create, edit and run programs"

Module Road Map. 7. Version Control with Subversion Introduction Terminology

Eclipse Tutorial. For Introduction to Java Programming By Y. Daniel Liang

Introduction to Eclipse

Eclipse Setup. Opening Eclipse. Setting Up Eclipse for CS15

Introduction to Eclipse

2 Getting Started. Getting Started (v1.8.6) 3/5/2007

Tutorial 02: Writing Source Code

CS520 Setting Up the Programming Environment for Windows Suresh Kalathur. For Windows users, download the Java8 SDK as shown below.

CONSUMING CUBEMASTER CALCULATION WEB SERVICE FROM JAVA Logen Solutions

INF160 IS Development Environments

ICOM 4015 Advanced Programming Laboratory. Chapter 1 Introduction to Eclipse, Java and JUnit

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer

CodeWarrior Development Studio for Power Architecture Processors FAQ Guide

Prerequisites for Eclipse

For live Java EE training, please see training courses at

User Guide Zend Studio for Eclipse V6.1

NetBeans Tutorial. For Introduction to Java Programming By Y. Daniel Liang. This tutorial applies to NetBeans 6, 7, or a higher version.

Using Eclipse Che IDE to develop your codebase. Red Hat Developers Documentation Team :15:48 UTC

CHAPTER 1INTRODUCTION... 3 CHAPTER 2INSTALLING ECLIPSE...

SDKs - Eclipse. SENG 403, Tutorial 2

Assignment 1. Application Development

Introduction to Computation and Problem Solving

Infor LN Studio Application Development Guide

Eclipse Quick Reference Windows Hosted

Eng. Mohammed S. Abdualal

1.00 Lecture 2. What s an IDE?

CodeWarrior Development Studio for Advanced Packet Processing FAQ Guide

Code Editor. The Code Editor is made up of the following areas: Toolbar. Editable Area Output Panel Status Bar Outline. Toolbar

JSF Tools Reference Guide. Version: M5

News in RSA-RTE 10.1 updated for sprint Mattias Mohlin, November 2017

Getting Started (1.8.7) 9/2/2009

Using Eclipse Che IDE to develop your codebase. Red Hat Developers Documentation Team :54:11 UTC

Adobe ColdFusion Documentation. September 2014

News in RSA-RTE 10.1 updated for sprint Mattias Mohlin, July 2017

5/3/2006. Today! HelloWorld in BlueJ. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont.

Coding Faster: Getting More Productive with Microsoft Visual

News in RSA-RTE 10.1 updated for sprint Mattias Mohlin, January 2018

ITEC102 INFORMATION TECHNOLOGIES

Visual Studio.NET. Although it is possible to program.net using only the command OVERVIEW OF VISUAL STUDIO.NET

Struts Tools Reference Guide. Version: beta1

CHAPTER 6. Java Project Configuration

i2b2 Workbench Developer s Guide: Eclipse Neon & i2b2 Source Code

Eclipse CDT Tutorial. Eclipse CDT Homepage: Tutorial written by: James D Aniello

ActiveSpaces Transactions. Quick Start Guide. Software Release Published May 25, 2015

6.170 Laboratory in Software Engineering Eclipse Reference for 6.170

Java Program Structure and Eclipse. Overview. Eclipse Projects and Project Structure. COMP 210: Object-Oriented Programming Lecture Notes 1

Figure 1. Simplicity Studio

A Guide to Quark Author Web Edition 2015

Drools Tools Reference Guide. Version: CR1

6L00IA - Introduction to Synergy Software Package Short Version (SSP v1.2.0) Renesas Synergy Family - S7 Series

3 CREATING YOUR FIRST JAVA APPLICATION (USING WINDOWS)

Getting Started with Eclipse/Java

David Scuse Department of Computer Science University of Manitoba. Eclipse 3.1

CHAPTER 3. Using Java Development Tools

Java with Eclipse: Setup & Getting Started

Code Autocomplete Manual

Imperative and Object Oriented Programming. Tutorial 1. Charlie Abela Department of Artificial Intelligence

Refactoring with Eclipse

Maintain an ILE RPG application using Remote System Explorer

Introduction. Key features and lab exercises to familiarize new users to the Visual environment

News in RSA-RTE 10.1 updated for sprint Mattias Mohlin, April 2017

3. NetBeans IDE 6.0. Java. Fall 2009 Instructor: Dr. Masoud Yaghini

MICROSOFT WORD 2010 Quick Reference Guide

DVT Eclipse IDE. My First Verilog/SystemVerilog Project

Wowza IDE 2. User's Guide

Table of Contents COURSE OVERVIEW... 3 LESSON 1: OUTLOOK 2010 CALENDAR INTERFACE... 5

MEDIA COMPUTATION DRJAVA. Lecture 11.3 November 7, 2008

UNic Eclipse Mini Tutorial (Updated 06/09/2012) Prepared by Harald Gjermundrod

Highline College. Busn 216: Computer Applications for Business (Fun and Power with Computers)

Code::Blocks Student Manual

Word 2013 Quick Start Guide

Setup and Getting Startedt Customized Java EE Training:

Corel Ventura 8 Introduction

Part I. Integrated Development Environment. Chapter 2: The Solution Explorer, Toolbox, and Properties. Chapter 3: Options and Customizations

Microsoft Office Training Skills 2010

Chapter 1 GETTING STARTED. SYS-ED/ Computer Education Techniques, Inc.

ECE QNX Real-time Lab

Transcription:

Abstract Lars Vogel <webmaster@vogella.de> Version 0.7 Copyright 2007 Lars Vogel 26.10.2007 Eclipse is a powerful, extensible IDE for building general purpose applications. One of the main applications of Eclipse is using it as a Java IDE (Integrated Development Environment). This article will describe the usage of Eclipse as a Java IDE. It contains a short introduction of the usage of Eclipse, discuss features of Eclipse which should increase the programmers productivity, lists the most important keyboard shortcuts and gives a few tips and tricks. Table of Contents 1. Installation... 2 2. Eclipse Overview... 2 2.1. Start Eclipse... 2 2.2. Workspace... 2 2.3. Eclipses User interface Elements... 2 2.4. Configuration of the perspective... 3 3. Create your first Java program in Eclipse... 3 3.1. "Hello Eclipse world!" console program... 3 4. Way of Working... 4 4.1. Powerful Time Savers... 5 4.2. Important Preference Settings... 6 4.3. Task Management... 6 4.4. Working Sets... 6 5. s... 6 5.1. Java Coding... 6 5.2. Editor... 7 5.3. Programming... 7 6. Helpful Settings... 8 6.1. Synchronize package explorer with code display... 8 6.2. Setting code and comments line widths / line length and text wrapping... 8 6.3. Local History... 8 6.4. Code Templates... 8 7. Addings jars to the build path... 9 8. Javadoc... 9 8.1. Using Javadoc in Eclipse... 9 8.2. Creating Javadoc with Eclipse... 9 9. Add source and the api description to Eclipse... 10 9.1. Add source code for external jars... 10 9.2. Add the API for a jar... 10 10. Links and Literature... 10 1

1. Installation Download Eclipse from the website http://www.eclipse.org/ and unpack it to any directly. Eclipse requires an installed Java as of version 1.4. Recommended it to use Java 6. 2. Eclipse Overview 2.1. Start Eclipse To start Eclipse double-click on the file Eclipse.exe in your installation directory. Close the welcome page by press in little x besides the Welcome. 2.2. Workspace The workspace is the physical location (file path) you are working in. You can choose the workspace during startup of eclipse or via the menu (File-> Switch Workspace-> Others). You can take parts of your settings which you did in your workspace to the next workspace. In your workspace all your sources files, images and other artefacts will be stored and saved. Note: To predefine the workspace you can use the startup parameter -data path_to_workspace, e.g. if your eclipse is located in c:\eclipse use the following to set the workscape to c:\temp. Please note that you have to put the path name into brackets. For example: c:\eclipse.exe -data "c:\temp" 2.3. Eclipses User interface Elements Eclipse provides perspectives, views and editors. Views and editors are grouped into perspectives. A perspective is a visual container for a set of views and editors (parts). Views provide information for a given task. A view is typically used to navigate a hierarchy of information, open an editor, or display properties for the active editor. Editors are meant for for the primary focus of attention and shows the main content of your application. The main differences between editor and views are not technical but semantic differences. Use editors for a task if this is a primary task. Technical differences: Editors are shared between perspectives, e.g. if you close an editor in one perspective it is closed in all perspectives. 2

You can asked for the active editor even if the editor is not in focus. This make updates of the active editor / access to the editor easier. To describe views and editors take the example of an email client. The navigation within the email client would be done via views, while the part of the application which is used for writing the email would be performed via an editor. 2.4. Configuration of the perspective You can change the layout within a perspective (close / open views, editors, change the size, change the position, etc.) A common problem at the beginning is that the perspective is accidently changed. Just use the menu "Window" -> "Reset Perspective" to set the perspective back to its original state. 3. Create your first Java program in Eclipse 3.1. "Hello Eclipse world!" console program The following will describe how to create a minimal Java program using Eclipse. Select from the menu File -> New-> Java project. Maintain "MyFirstProject" has the project name. Select Create separate source and output folders. Press finish. Open the folder, select the folder src, right mouse click on it and select create package. Create package mypackage. Right click on your package and select New -> Class Create MyFirstClass, select the flag "public static void main (String[] args)" Maintain the following code. package mypackage; public class MyFirstClass { 3

} /** * @param args */ public static void main(string[] args) { System.out.println("Hello Eclipse World!"); } Now run your code. Finished! You should see the output in the console. 4. Way of Working Eclipse provides tremendous help during programming. Even though it is not possible to describe all then following tried to highlight a few nice features. The killer helpers are Content Help Quick Fix 4

Table 1. 4.1. Powerful Time Savers If you press Enter during code assistant then the cursor will go to the end of the line. Using Eclipse Europa - A Tutorial Or type in the coding Ex and then press [Ctrl + Space] to get a list of all types which starts with Ex. Or if you have type variable test. and then press [Ctrl + Space] you get all the possible methods. Allows also to define variables based on the camelcase notation. So you can type NPE and press [Ctrl+Space] to get the Types which have the three capital letters included, e.g. NullPointerException. Generated Getters and setters Quick Fix The content assistant is also available for the definition of variables. For example define a variable "private String" and the press [Ctrl+Space] to define the name automatically. By default it will use the name of the type. If you want to add a prefix / suffix you can do this under Windows-Preferences and here Java -> Code Style. To create getter and setter methods for a field, select the field's declaration and invoke Source > Generate Getter and Setter. Whenever there is a problem Eclipse will underline the problematic place in the coding. Select this and press (Ctrl+1) For example type "myboolean = true;" If myboolean is not yet defined, Eclipse will highlight it as an error. Select the variable and press "Ctrn+1", then Eclipse will suggest to create a field or local variable. You can also use Quick Fix to create a new local / field variable for a parameter of the method. Select in the method the parameter and press Quick Fix to get the option to "Assign the parameter to new field". You can also use Quick Fix to create a method for an object. Just type the call of the method. Eclipse will indicate that this method does not exists. Press Quick Fix to get the option to create this method. You can also use Quick Fix to handle Exceptions, e.g. create the try / catch block for you, or add a through exception to the method. You can also use Quick Fix to assign a statement to a new variable. Lets assume you have the statement a.calculatesomething(); whereby calculatesomething returns an integer. Select the statement and press Quick Fix to assign it to a new local / field variable. With a Quick Fix you can also check the spelling of types words. 5

4.2. Important Preference Settings Eclipse allows to set semicolons (and other elements) automatically. Eclipse let you also configure the errors / warnings it displays. Eclipse allows to format the source code and to organize the imports at save. 4.3. Task Management If you use // TODO in the coding this indicates a task for eclipse and you find it in the task view of Eclipse. 4.4. Working Sets A common problem in Eclipse is that your data in your workspace grows and therefore your workspace is not well structured anymore. You can use working sets to organize your displayed projects / data. To setup your working set select in the Package Explorer -> Show -> Working Sets. Press new on the following dialog to create a working set. On the following dialog select java, select the source folder you would like to see and give it a name. You can now easily display only the files you want to see. 5. s 5.1. Java Coding Table 2. Important shortcuts Ctrl + S Alt + Shift + X - J Ctrl + Shift + F Ctrl + Shift + O Ctrl + Shift + R Alt + Left / Alt + right Alt + Strg + 0 Alt + Strg + 7 Save Run as Java application Format source code Organize the imports / Will import the missing imports. Refactor / Rename method / variable Go back to last position/ Go to next position } (Easier to reach then AltGr + 0) { (Easiwer to reach then AltGr + 7) 6

5.2. Editor Table 3. Important s Ctrl + Alt + Down Ctrl + D Pos1 End Ctrl + Q Ctrl + M Copy line Deletes line Line Start Line End Last edited position Full screen mode for java coding and back Table 4. Search Alt+Left Alt-Right Ctrl + Mausclick on a variable Ctrl +. F3 on a variable Strg + J, Strg +k Go to prev/ next editor position in history Go to declaration of this variable Go to previous / next problem Goto Declaration of this variable Incremental search, find next Table 5. Selecting Ctrl + Shift + Left Ctrl + Shift + Right Alt + Shift + Left Alt + Shift + Right Ctrl + Entf Ctrl + Left Ctrl + Right Select previous word Select next word Select previous element Select previous element Delete next element Move one element to the left Move one element to the right 5.3. Programming Table 6. Important shortcuts Ctrl F11 F12 Ctrl + Shift + P Alt + Shift + Z Run last launched Focus to editor window Go to matching bracket Surround block with try and catch 7

Table 7. Debugging Cntl + Shift + B F11 F5 F6 F7 Toggle breakpoint Debug last run Single Step (Down) Single Step (Jump) Up 6. Helpful Settings 6.1. Synchronize package explorer with code display On the package explorer select the arrow down menu on the right upper corner (menu). Here you find the display settings. Select the last entry "Link with Editor". This is also available on the menu via the double arrow buttons. With this selection the package explorer will always show the source file you selected in the editor. Example: if you working on foo.java and you change in the editor to bar.java then the display in the package explorer will change. 6.2. Setting code and comments line widths / line length and text wrapping Code line wrapping is set in Preferences->Java->Code Style- >Formatter, then click on the Edit button and select the Line Wrapping tab. Comment width and line wrapping is set in Preferences->Java->Code Style->Formatter, then click on the Edit button and select the Comments tab. Indentation is set separately, in Preferences->Java->Code Style- >Formatter, then click on the Edit button and select the Indentation tab. 6.3. Local History Eclipse stores for each file a local history which you can use to retrieve an older version of the file even without using a version control system. Double-click on on Revision Time in the history view to see the differences. 6.4. Code Templates If you have to type frequently the same code / part of the document you can maintain templates which can be activate via autocomplete (Ctrl + Space). For example lets assume you are using Eclipse to edit XML files and have to write the following text frequently only with a different file name. 8

<para> <programlisting> <xi:include xmlns:xi="http://www.w3.org/2001/xinclude" parse="text" href="../examples/java/wizard/mypagetwo.java" /> </programlisting> </para> To create a template for this select the menu Window->Preferences and Open Web and XML -> XML Files-> Templates Press New. Create the following template. ${cursor} indicates that the cursor should be placed at this position after applying the template. Now every time you type the keyword and press Ctrl+Space the system will proposal to add the additional text. 7. Addings jars to the build path To add external jars to your project perform the following: Create a new folder called lib or use your existing folder Select import -> file system -> import the.jar Select your project, right mouse click and select properties. Under libraries select Add JARs and under Order and Export include your jar file and move it up to avoid conflicts. The following example shows how the result would look like if junit-4.4.jar would be added to a project. 8. Javadoc 8.1. Using Javadoc in Eclipse To call the Javadoc for a type / class / method, position the cursor on the keyword and press Shift + F2. 8.2. Creating Javadoc with Eclipse To create Javadoc from Eclipse for your coding, select File -> Export. Select then Javadoc and follow the wizard. 9

The javadoc command is the javadoc.exe file which you will find in your jdk installation directory. 9. Add source and the api description to Eclipse 9.1. Add source code for external jars To browse the source of a type contained in library you can attach a source archive or source folder to this library. The editor will then show the source instead of a the decompiled code. Setting the source attachment also allows source level stepping with the debugger. The Source Attachment dialog can be reached via: Open the Java Build Path page of a project (Projects > Properties > Java Build Path). On the Libraries page expand the library's node and select the Source attachment attribute and press Edit Maintain the location to the source attachement. In the Location path field, enter the path of an archive or a folder containing the source. 9.2. Add the API for a jar Download the API of the jar and put it somewhere in your filesystem. Open the Java Build Path page of a project (Projects > Properties > Java Build Path). On the Libraries page expand the library's node and select the Javadoc location attribute and press Edit Maintain the location to the api. 10. Links and Literature http://www.eclipse.org/ - Eclipse Website [http://www.eclipse.org/] http://www.vogella.de/articles/eclipse/article.html - Using Eclipse as IDE - Tutorial www.vogella.de/articles/eclipse/article.html] [http:// http://www.vogella.de/articles/richclientplatform/article.html - Eclipse Rich Client Platform Tutorial - A Hands-on-Guide [http://www.vogella.de/articles/richclientplatform/article.html] http://www.vogella.de/articles/eclipsemicrosoftintegration/article.html - Eclipse Microsoft Integration (Outlook )- Tutorial [http://www.vogella.de/articles/eclipsemicrosoftintegration/article.html] http://www.vogella.de/articles/eclipsecodeaccess/article.html - Goto the source - A guide to access the Eclipse Sources [http://www.vogella.de/articles/eclipsecodeaccess/article.html] 10