8/21/2019 Eclipse Quick Guide
1/28
An Introduction to Eclipse:
Quick Guide
Part 1: Getting Started with Eclipse Part 2: Working with Eclipse
Part 3: Using Subversion (SVN)
Useful Online Guides
Tuesday, 9 October 12
8/21/2019 Eclipse Quick Guide
2/28
Part 1: Getting Started with Eclipse
Installation & Running
The User Interface Creating a Project
Creating a Class
Running a Project Navigating Projects
Tuesday, 9 October 12
8/21/2019 Eclipse Quick Guide
3/28
Installation and Running
Check java is present and up-to-date: java -version
Download from http://www.java.com/en/download/manual.jsp
Eclipse Enterprise Edition: http://www.eclipse.org/downloads/ Unzip and install (win: http://www.7-zip.org/ if needed)
Run:
windows: eclipse.exe linux / os x: eclipse application
in the lab: Root > opt > eclipse-3.7 > eclipse
Tuesday, 9 October 12
http://www.7-zip.org/http://www.eclipse.org/downloads/http://www.7-zip.org/http://www.7-zip.org/http://www.eclipse.org/downloads/http://www.eclipse.org/downloads/http://www.java.com/http://www.java.com/8/21/2019 Eclipse Quick Guide
4/28
The User Interface
Projects &
Classes
Methods &Attributes
Output
Editor
Current
Perspective
Tuesday, 9 October 12
8/21/2019 Eclipse Quick Guide
5/28
Creating a New Project
[right-click]
1 2
3
4
Tuesday, 9 October 12
8/21/2019 Eclipse Quick Guide
6/28
Creating a Class
[right-click]
can auto-generate main method stub
right-click on the location / packagewhere you want to place this class
1 2
Tuesday, 9 October 12
8/21/2019 Eclipse Quick Guide
7/28
Running a ProjectIn Eclipse: From command line:
Navigate to ProjectName/binfolder to execute
If your project is packaged thenfrom bin use java packageName/className to execute
Tuesday, 9 October 12
8/21/2019 Eclipse Quick Guide
8/28
Navigating Projects
Selecting an item in one view brings it into focus in the other views
Tuesday, 9 October 12
8/21/2019 Eclipse Quick Guide
9/28
Part 2: Working with Eclipse
Creating Packages
Automatic Code Generation
Importing System Classes intoProjects Importing System andUser Libraries
Debugging
Refactoring Creating jars
Other Useful Features
Tuesday, 9 October 12
8/21/2019 Eclipse Quick Guide
10/28
Creating Packages1
2
By convention these are named inmyPackage style, just like classes
If you move classes between packagesEclipse will automatically fix referencesin other classes, and add importstatements where needed
Tuesday, 9 October 12
8/21/2019 Eclipse Quick Guide
11/28
Automatic Code Generation
Eclipse can automatically generate constructors andsome frequently used methods
With a class open in the Editor view, use the Sourcemenu item as apt
Hover on a problem notification to see the Quick Fixoptions:
select one, then [control+enter] to invoke
it can fix import declarations and most simple (nonruntime) coding errors
Tuesday, 9 October 12
8/21/2019 Eclipse Quick Guide
12/28
Importing System ClassesProblem: Types ArrayList and Color are not recognised
Solution:Automatically import the classes
Tuesday, 9 October 12
8/21/2019 Eclipse Quick Guide
13/28
Importing Libraries
For other libraries we select Add ExternalJars then navigate as apt
This adds a JRE System Library1
2
3
Tuesday, 9 October 12
8/21/2019 Eclipse Quick Guide
14/28
Debugging
Red warnings are items that might cause the program to fail to run
depends if the code is reachable
Yellow warnings are advisory:
attributes, methods and imports that are never used
non-generic Collection types in use:
such asArrayListversusArrayList
Hover on the warning for info, use Quick-Fixwhere apt
Runtime errors can be traced from Console to the guilty line of code in Editor:
click on the error to see the line in focus
Visit http://www.ibm.com/developerworks/library/os-ecbug/ for a guide to the moreadvanced inbuilt debugging features
Tuesday, 9 October 12
http://www.ibm.com/developerworks/library/os-ecbug/http://www.ibm.com/developerworks/library/os-ecbug/http://www.ibm.com/developerworks/library/os-ecbug/8/21/2019 Eclipse Quick Guide
15/28
Refactoring
Eclipse can rename methods and attributes across thewhole scope of a project
[double-click] on a method or attribute name > Refactor
> Rename
Optionally, old methods can be retained and deprecated:
Tuesday, 9 October 12
8/21/2019 Eclipse Quick Guide
16/28
Creating Jars
JAR which includes source code (say for sharing work)
[right-click] on project
Export > Java > JAR File > Next
select Export java source files and resources
Name the JAR
Runnable JAR (source code omitted, but includes externally referenced libraries)
[right-click] on project Export > Java > Runnable JAR File > Next
Select Launch Configuration: Extract External Files
Name the JAR
About Launch Configuration:
Extract:external JARs will beextracted and the class files put/mixedtogether with your c lass files
Package: external JARs will remain asJARs in the root of your archive
Tuesday, 9 October 12
8/21/2019 Eclipse Quick Guide
17/28
Other Useful Features
To highlight the scope of { } parentheses, [double-click] justafter the opening parenthesis
Add // TODO comments to your code to manage work-in-
progress
View the TODO list using the Taskview, NOT the TaskListview
Click on an item to bring it to focus in other views
File Handling: the default working directory for files is thetop level directory for the project, NOTthe (src) directorycontaining the source code
Tuesday, 9 October 12
8/21/2019 Eclipse Quick Guide
18/28
Part 3: Using Subversive (SVN)
Installing Subversive
Adding a New Repository Location
Adding, Moving and Removing Content Sharing a Project
Check Out Files and Folders
CommitChanges Revert Changes
Suggested Practice Exercise
Tuesday, 9 October 12
8/21/2019 Eclipse Quick Guide
19/28
Installing Subversive
visit: http://www.eclipse.org/subversive/documentation/gettingStarted/aboutSubversive/install.php
general guidance: http://www.eclipse.org/subversive/documentation/index.php
Tuesday, 9 October 12
http://www.eclipse.org/subversive/documentation/index.phphttp://www.eclipse.org/subversive/documentation/index.phphttp://www.eclipse.org/subversive/documentation/index.phphttp://www.eclipse.org/subversive/documentation/index.phphttp://www.eclipse.org/subversive/documentation/index.phphttp://www.eclipse.org/subversive/documentation/gettingStarted/aboutSubversive/install.phphttp://www.eclipse.org/subversive/documentation/gettingStarted/aboutSubversive/install.phphttp://www.eclipse.org/subversive/documentation/gettingStarted/aboutSubversive/install.phphttp://www.eclipse.org/subversive/documentation/gettingStarted/aboutSubversive/install.php8/21/2019 Eclipse Quick Guide
20/28
Adding a New Repository Location
12
Tuesday, 9 October 12
8/21/2019 Eclipse Quick Guide
21/28
Adding, Moving and Removing Content
In SVN Repository Exploring View:
Adding a newFolder to the repository:
[right-click] on location > New > Folder >
Adding existing Files (including folders!): [right-click] on location > New > File >
Move File: [select-and-drag] as apt
Delete File: [right-click] on file > Delete
Tuesday, 9 October 12
8/21/2019 Eclipse Quick Guide
22/28
Sharing a Project
1 2
3
4
do in Java viewmust refresh the SVN view to see it thereeasy to change projects location in SVN view
Tuesday, 9 October 12
8/21/2019 Eclipse Quick Guide
23/28
Check Out Files & Folders
Tuesday, 9 October 12
8/21/2019 Eclipse Quick Guide
24/28
Commit Changes
1
2
alwaysmake a comment
Tuesday, 9 October 12
8/21/2019 Eclipse Quick Guide
25/28
Revert Changes (Locally)
when the changes have happened within this session
Tuesday, 9 October 12
8/21/2019 Eclipse Quick Guide
26/28
Revert Changes (from Repository)
when the changes are historic or were done elsewhere
1
2
Tuesday, 9 October 12
8/21/2019 Eclipse Quick Guide
27/28
Suggested Practice Exercise
create a simple project in Eclipse
a couple of classes will do
then make a backup copy outside of your Eclipse workspace folder
share it to the team repository
go to SVN Repository perspective and refresh the view
move the project into sandbox
delete the local copy of the project from your Eclipse workspace
check the box to also delete contents on disc
now check out the project from the repository
justthe project, not the whole repository
go to Java perspective and make trivial changes to the code
commit the changes
try having a couple of team members simultaneously make changes (to different classes) in the project
Tuesday, 9 October 12
8/21/2019 Eclipse Quick Guide
28/28
Useful Online Guides
Lars Vogels Eclipse IDE Tutorial
http://www.vogella.de/articles/Eclipse/article.html
David Scuses guide to Eclipse 3.1
http://www.cs.umanitoba.ca/~eclipse/Eclipse3-1.pdf
Debugging with the Eclipse Platform
http://www.ibm.com/developerworks/library/os-ecbug/
Eclipse Current Release User Guide
http://help.eclipse.org/indigo/index.jsp
Book/eBook: Eclipse IDE Pocket Guideby Ed Burnette (OReilly Publishing)
(which also form the reference materials for this guide)
http://help.eclipse.org/indigo/index.jsphttp://www.ibm.com/developerworks/library/os-ecbug/http://www.cs.umanitoba.ca/~eclipse/Eclipse3-1.pdfhttp://help.eclipse.org/indigo/index.jsphttp://help.eclipse.org/indigo/index.jsphttp://www.ibm.com/developerworks/library/os-ecbug/http://www.ibm.com/developerworks/library/os-ecbug/http://www.cs.umanitoba.ca/~eclipse/Eclipse3-1.pdfhttp://www.cs.umanitoba.ca/~eclipse/Eclipse3-1.pdfhttp://www.vogella.de/articles/Eclipse/article.htmlhttp://www.vogella.de/articles/Eclipse/article.html