03 using eclipse
DESCRIPTION
03 Using Eclipse. IDE Overview. An IDE is an Interactive Development Environment Different IDEs meet different needs BlueJ and DrJava are designed as teaching tools - Emphasis is on ease of use for beginners - Little to learn, so students can concentrate on learning Java - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: 03 Using Eclipse](https://reader035.vdocuments.site/reader035/viewer/2022062500/56815989550346895dc6c9c1/html5/thumbnails/1.jpg)
03 Using Eclipse
![Page 2: 03 Using Eclipse](https://reader035.vdocuments.site/reader035/viewer/2022062500/56815989550346895dc6c9c1/html5/thumbnails/2.jpg)
2
IDE OverviewIDE Overview
• An IDE is an Interactive Development Environment
• Different IDEs meet different needs• BlueJ and DrJava are designed as teaching tools
- Emphasis is on ease of use for beginners
- Little to learn, so students can concentrate on learning Java• Eclipse, JBuilder and IntelliJ are designed as professional-level
work tools
- Emphasis is on supporting professional programmers
- More to learn, but well worth it in the long run
• We will use Eclipse
![Page 3: 03 Using Eclipse](https://reader035.vdocuments.site/reader035/viewer/2022062500/56815989550346895dc6c9c1/html5/thumbnails/3.jpg)
3
Eclipse OverviewEclipse Overview
Platform Runtime
Workspace
Help
Team
Workbench
JFace
SWT
Eclipse Project
JavaDevelopment
Tools(JDT)
Their Tool
Your Tool
AnotherTool
Plug-inDevelopmen
tEnvironment
(PDE)
Eclipse Platform
Debug
![Page 4: 03 Using Eclipse](https://reader035.vdocuments.site/reader035/viewer/2022062500/56815989550346895dc6c9c1/html5/thumbnails/4.jpg)
4
What is Eclipse?What is Eclipse?
• Eclipse is a universal platform for integrating development tools
• Open, extensible architecture based on plug-ins
Java Virtual Machine
Eclipse Platform
Java Development Tools
Plug-in development environment
![Page 5: 03 Using Eclipse](https://reader035.vdocuments.site/reader035/viewer/2022062500/56815989550346895dc6c9c1/html5/thumbnails/5.jpg)
5
Workbench TerminologyWorkbench Terminology
Tool bar
Perspective
and
Fast View
bar
Resource
Navigator
view
Stacked
views
Properties
view
Tasks
view
Outline
view
Bookmarks
view
Menu bar
Editor
Status
area
Text
editor
Click to display the label…
![Page 6: 03 Using Eclipse](https://reader035.vdocuments.site/reader035/viewer/2022062500/56815989550346895dc6c9c1/html5/thumbnails/6.jpg)
6
Help ComponentHelp Component
• Help is presented in a standard web browser
![Page 7: 03 Using Eclipse](https://reader035.vdocuments.site/reader035/viewer/2022062500/56815989550346895dc6c9c1/html5/thumbnails/7.jpg)
7
Java PerspectiveJava Perspective
• Java-centric view of files in Java projects
• Java elements meaningful for Java
Javaproject
package
class
field
method
Javaeditor
![Page 8: 03 Using Eclipse](https://reader035.vdocuments.site/reader035/viewer/2022062500/56815989550346895dc6c9c1/html5/thumbnails/8.jpg)
8
Java PerspectiveJava Perspective
Typehierarchy
Selectedtype’s
members
• Browse type hierarchies• “Up” hierarchy to supertypes• “Down” hierarchy to subtypes
![Page 9: 03 Using Eclipse](https://reader035.vdocuments.site/reader035/viewer/2022062500/56815989550346895dc6c9c1/html5/thumbnails/9.jpg)
9
Java PerspectiveJava Perspective
• Search for Java elements• Declarations or references• Including libraries and other projects
Hitsflaggedin marginof editor
All search results
![Page 10: 03 Using Eclipse](https://reader035.vdocuments.site/reader035/viewer/2022062500/56815989550346895dc6c9c1/html5/thumbnails/10.jpg)
10
Java EditorJava Editor
• Hovering over identifier shows Javadoc spec• Method completion in Java editor
List of plausible methods Doc for method
![Page 11: 03 Using Eclipse](https://reader035.vdocuments.site/reader035/viewer/2022062500/56815989550346895dc6c9c1/html5/thumbnails/11.jpg)
11
Java EditorJava Editor
• On-the-fly spell check catches errors early• Code templates help with drudgery
Statementtemplate Preview
![Page 12: 03 Using Eclipse](https://reader035.vdocuments.site/reader035/viewer/2022062500/56815989550346895dc6c9c1/html5/thumbnails/12.jpg)
12
Java EditorJava Editor
• Java editor creates stub methods• Java editor helps programmers write good Java code
Variable namesuggestion
Argument hints andproposed argumentnames
JavaDoccode assist
![Page 13: 03 Using Eclipse](https://reader035.vdocuments.site/reader035/viewer/2022062500/56815989550346895dc6c9c1/html5/thumbnails/13.jpg)
13
RefactoringRefactoring
• JDT has actions for refactoring Java code
![Page 14: 03 Using Eclipse](https://reader035.vdocuments.site/reader035/viewer/2022062500/56815989550346895dc6c9c1/html5/thumbnails/14.jpg)
14
RefactoringRefactoring
• Full preview of all ensuing code changes• Programmer can veto individual changes
List of changes
“before” vs. “after”
![Page 15: 03 Using Eclipse](https://reader035.vdocuments.site/reader035/viewer/2022062500/56815989550346895dc6c9c1/html5/thumbnails/15.jpg)
15
Eclipse Java DebuggerEclipse Java Debugger
• Run or debug Java programs
Threads and stack
frames
Editor with breakpoint
marks
Console I/O
Local variables
![Page 16: 03 Using Eclipse](https://reader035.vdocuments.site/reader035/viewer/2022062500/56815989550346895dc6c9c1/html5/thumbnails/16.jpg)
16
ContentsContents
• How To Create Java Project• How To Add Folder• How To Configure Java Project• How To Create Java Package• How To Create Java Application• How To Run Java Application• How To Debug a Java Application• Configuring Library Build Path• Resources
![Page 17: 03 Using Eclipse](https://reader035.vdocuments.site/reader035/viewer/2022062500/56815989550346895dc6c9c1/html5/thumbnails/17.jpg)
17
How To Create Java ProjectHow To Create Java Project
• Double-click the Eclipse icon on your desktop.
• Select File New Project…
![Page 18: 03 Using Eclipse](https://reader035.vdocuments.site/reader035/viewer/2022062500/56815989550346895dc6c9c1/html5/thumbnails/18.jpg)
18
How To Create Java ProjectHow To Create Java Project
• Select Java Project in the ‘New Project’ window.
• Click Next.
![Page 19: 03 Using Eclipse](https://reader035.vdocuments.site/reader035/viewer/2022062500/56815989550346895dc6c9c1/html5/thumbnails/19.jpg)
19
How To Create Java ProjectHow To Create Java Project
• Choose a non-existing name for the project. In this example, choose ‘FirstJavaProject’.
• Click Finish.
Back to Main
![Page 20: 03 Using Eclipse](https://reader035.vdocuments.site/reader035/viewer/2022062500/56815989550346895dc6c9c1/html5/thumbnails/20.jpg)
20
How To Add FolderHow To Add Folder
For example, you need to add lib, src and classes folder:
1. Right-click the project name, in this example, FirstJavaProject. Select New Folder…
![Page 21: 03 Using Eclipse](https://reader035.vdocuments.site/reader035/viewer/2022062500/56815989550346895dc6c9c1/html5/thumbnails/21.jpg)
21
How To Add FolderHow To Add Folder
2. Enter lib in the ‘Folder name’ textbox of the ‘New Folder’ dialog box.
3. Click Finish.
Repeat steps 1 to 3 to add src and classes folder.
Back to Main
![Page 22: 03 Using Eclipse](https://reader035.vdocuments.site/reader035/viewer/2022062500/56815989550346895dc6c9c1/html5/thumbnails/22.jpg)
22
How To Configure Java ProjectHow To Configure Java Project
• Right-click the project name, in this example, FirstJavaProject.
• Select Properties.
![Page 23: 03 Using Eclipse](https://reader035.vdocuments.site/reader035/viewer/2022062500/56815989550346895dc6c9c1/html5/thumbnails/23.jpg)
23
How To Configure Java ProjectHow To Configure Java Project
• Select Java Build Path in the ‘Properties’ dialog box. Configure the following:
1. Source set to ‘src’ folder.
Click the Add Folder… button. The ‘Source Folder Selection’ dialog box appears. Select the ‘src’ folder. Click OK.
![Page 24: 03 Using Eclipse](https://reader035.vdocuments.site/reader035/viewer/2022062500/56815989550346895dc6c9c1/html5/thumbnails/24.jpg)
24
How To Configure Java ProjectHow To Configure Java Project
2. Set the default output folder to FirstJavaProject\classes
Click the Browse… button. The ‘Folder Selection’ dialog box appears. Select the classes folder.
Click OK.
NOTE:
Default output folder would be changed to FirstJavaProject\classesBack to Main
![Page 25: 03 Using Eclipse](https://reader035.vdocuments.site/reader035/viewer/2022062500/56815989550346895dc6c9c1/html5/thumbnails/25.jpg)
25
How To Create Java PackageHow To Create Java Package
• Select File New Package
![Page 26: 03 Using Eclipse](https://reader035.vdocuments.site/reader035/viewer/2022062500/56815989550346895dc6c9c1/html5/thumbnails/26.jpg)
26
How To Create Java PackageHow To Create Java Package
• Enter the package name, firstJavaPackage, in the ‘Name’ textbox of the ‘New Java Package’ dialog box.
• Click Finish.
Back to Main
![Page 27: 03 Using Eclipse](https://reader035.vdocuments.site/reader035/viewer/2022062500/56815989550346895dc6c9c1/html5/thumbnails/27.jpg)
27
How To Create Java ClassHow To Create Java Class
• To create a Java Class, right-click the package name, in this example, firstJavaPackage.
• Select New Class
![Page 28: 03 Using Eclipse](https://reader035.vdocuments.site/reader035/viewer/2022062500/56815989550346895dc6c9c1/html5/thumbnails/28.jpg)
28
How To Create Java ClassHow To Create Java Class
• The ‘New Java Class’ dialog box appears. Enter the class name in the ‘Name’ text box. For this instance enter ‘Example’.
• Click Finish.
![Page 29: 03 Using Eclipse](https://reader035.vdocuments.site/reader035/viewer/2022062500/56815989550346895dc6c9c1/html5/thumbnails/29.jpg)
29
How To Create Java ClassHow To Create Java Class• Complete the Java Class in the Java editor screen…
Back to Main
![Page 30: 03 Using Eclipse](https://reader035.vdocuments.site/reader035/viewer/2022062500/56815989550346895dc6c9c1/html5/thumbnails/30.jpg)
30
How To Run Java ClassHow To Run Java Class
• To run the class, select the Java File.
• On the Menu bar, select Run Run As Java Application
• This will show the results on the Console view.
Back to Main
![Page 31: 03 Using Eclipse](https://reader035.vdocuments.site/reader035/viewer/2022062500/56815989550346895dc6c9c1/html5/thumbnails/31.jpg)
31
How To Debug a Java ApplicationHow To Debug a Java Application
• Right-click the JavaMainClass, in this example, TestCard.java
• Select Debug Java Application.
• The Debug perspective screen will appear.
![Page 32: 03 Using Eclipse](https://reader035.vdocuments.site/reader035/viewer/2022062500/56815989550346895dc6c9c1/html5/thumbnails/32.jpg)
32
How To Debug a Java ApplicationHow To Debug a Java Application
![Page 33: 03 Using Eclipse](https://reader035.vdocuments.site/reader035/viewer/2022062500/56815989550346895dc6c9c1/html5/thumbnails/33.jpg)
33
How To Debug a Java ApplicationHow To Debug a Java Application
Set Breakpoints
• Place your cursor on the marker bar (along the left edge of the editor area) on the line including the suspected code.
• Double-click to set the breakpoint
NOTE:
Two breakpoint markers in the left margin of the editor.
![Page 34: 03 Using Eclipse](https://reader035.vdocuments.site/reader035/viewer/2022062500/56815989550346895dc6c9c1/html5/thumbnails/34.jpg)
34
Configuring Library Build PathConfiguring Library Build Path
• Right-click the project name, in this example, “Sample” project.
• Select Properties.
How to add jar files
![Page 35: 03 Using Eclipse](https://reader035.vdocuments.site/reader035/viewer/2022062500/56815989550346895dc6c9c1/html5/thumbnails/35.jpg)
35
Configuring Library Build PathConfiguring Library Build Path
• In the ‘Properties’ dialog box, select the ‘Libraries’ tab.
• Click the Add External … button
![Page 36: 03 Using Eclipse](https://reader035.vdocuments.site/reader035/viewer/2022062500/56815989550346895dc6c9c1/html5/thumbnails/36.jpg)
36
Configuring Library Build PathConfiguring Library Build Path
• In the ‘JAR Selection’ dialog box, select the ‘plugins’ folder.
• Click the Open button.
OR
• Double-click the ‘plugins’ folder.
![Page 37: 03 Using Eclipse](https://reader035.vdocuments.site/reader035/viewer/2022062500/56815989550346895dc6c9c1/html5/thumbnails/37.jpg)
37
Configuring Library Build PathConfiguring Library Build Path
• In the ‘JAR Selection’ dialog box, look for the specific ‘junit’ folder with the required version. In this example we are using junit 3.8.1.
• After selection, Click the Open button
OR
• Double Click the selected junit folder.
![Page 38: 03 Using Eclipse](https://reader035.vdocuments.site/reader035/viewer/2022062500/56815989550346895dc6c9c1/html5/thumbnails/38.jpg)
38
Configuring Library Build PathConfiguring Library Build Path
• Select the ‘junit.jar’ file in the ‘JAR Selection’ dialog box.
• Click the Open button.
OR
• Double-click the selected ‘junit’ folder.
![Page 39: 03 Using Eclipse](https://reader035.vdocuments.site/reader035/viewer/2022062500/56815989550346895dc6c9c1/html5/thumbnails/39.jpg)
39
Configuring Library Build PathConfiguring Library Build Path
• You should see that the ‘jar’ file has been added to the ‘Properties’ dialog box..
• Click OK.
Back to Main
![Page 40: 03 Using Eclipse](https://reader035.vdocuments.site/reader035/viewer/2022062500/56815989550346895dc6c9c1/html5/thumbnails/40.jpg)
40
ResourcesResources
• Eclipse Website
http://www.eclipse.org/
• Eclipse Documentation
http://www.eclipse.org/documentation/main.html
Debug Documentation• http://www.linuxdevices.com/articles/AT6046208714.html