670 likes | 794 Views
INF160 IS Development Environments AUBG, COS dept. Lecture 06 Title: Dev Env: Eclipse (Extract from Syllabus) Reference: www.eclipse.org. Lecture Sources:. http://help.eclipse.org/kepler/index.jsp http://agile.csc.ncsu.edu/SEMaterials/tutorials/eclipse/eclipse_tutorial_3.3.html
E N D
INF160 IS Development Environments AUBG, COS dept Lecture 06 Title: Dev Env: Eclipse (Extract from Syllabus) Reference: www.eclipse.org
Lecture Sources: • http://help.eclipse.org/kepler/index.jsp • http://agile.csc.ncsu.edu/SEMaterials/tutorials/eclipse/eclipse_tutorial_3.3.html • Laurie Williams, Dright Ho, Ben Smith and Sarah Heckman • CSC 326 - Software Engineering • Dept of COS, North Carolina State University
Lecture Contents: • Eclipse – introduction • Eclipse – functionality • Eclipse – configuration
Eclipse – introduction • Eclipse is a multi-language software development environment comprising an integrated development environment (IDE) and an extensible plug-in system. It is written mostly in Java and can be used to develop applications in Java and, by means of various plug-ins, other programming languages including Ada, C, C++, COBOL, Perl, PHP, Python, R, Ruby, Scala, and Scheme. The IDE is often called • Eclipse ADT (Ada Development Toolkit) for Ada, • Eclipse CDT for C/C++, • Eclipse JDT for Java, • Eclipse PDT for PHP.
Eclipse – Basic terms • Project Eclipse creates Java application, using the Project concept – a folder to save all associated project files. • Workspace Eclipse stores projects in a folder, called a workspace. At starting time, user is asked to choose a concrete folder to be used as workspace for current session.
Eclipse – Basic terms • Workbench • Resource • Perspective • Editor • View
Eclipse – Basic terms • Workbench The term Workbench refers to the desktop development environment. Each Workbench window contains one or more perspectives. Perspectives contain views and editors and control what appears in certain menus and tool bars.
Sample workbench description • Displayed in a frame. Includes title, Menu bar, Icon tools bar, Collection of views and editors
Eclipse – Basic terms • Resource • Resources is a collective term for the projects, folders, and files that exist in the Workbench. The navigation views provide a hierarchical view of resources and allows you to open them for editing. • There are three basic types of resources that exist in the Workbench: • Files • Folders • Projects
Eclipse – Basic terms • Files Comparable to files as you see them in the file system.
Eclipse – Basic terms • Files Comparable to files as you see them in the file system. • Folders Comparable to directories on a file system. In the Workbench, folders are contained in projects or other folders. Folders can contain files and other folders.
Eclipse – Basic terms • Files Comparable to files as you see them in the file system. • Folders Comparable to directories on a file system. In the Workbench, folders are contained in projects or other folders. Folders can contain files and other folders. • Projects Contain folders and files. Projects are used for builds, sharing, and resource organization. Like folders, projects map to directories in the file system. (When you create a project, you specify a location for it in the file system.)
Eclipse – Basic terms • A project is either open or closed. • When a project is closed, it cannot be changed in the Workbench. The resources of a closed project will not appear in the Workbench, but the resources still reside on the local file system. Closed projects require less memory. Since they are not examined during builds, closing a project can improve build time. • When a project is open, the structure of the project can be changed and you will see the contents.
Eclipse – Basic terms • Resource hierarchies Resources are stored and displayed in the Workbench in hierarchies. Described below are the terms used when referring to resources that are stored and displayed in a hierarchical structure.
Eclipse – Basic terms • Resource hierarchies • Root • The top level of the Workbench contents (in the file system). • Parent resource • Any resource that contains another resource. Only projects and folders can be parent resources. • Child resource • Any resource that is contained within another resource. Only files and folders can be child resources. • Resource hierarchies are displayed in the Project Explorer view, which is one of the default views in the Resource perspective.
Eclipse • Project Explorer view • The Project Explorer view provides a hierarchical view of the resources in the Workbench. From here, you can open files for editing or select resources for operations such as exporting. • Right-click on any resource in the Project Explorer view to open a pop-up menu that allows you to perform operations such as copying, moving, creating new resources, comparing resources with each other, or performing team operations. To see a description of what each menu item does, move selection highlight to that menu item and press the context-sensitive help key (e.g., F1 on Microsoft Windows). • By default, the Project Explorer view is included in the Resources perspective. To add it to the current perspective, click Window > Show View > Other... > General > Project Explorer.
Eclipse – Basic terms • Perspective • Each Workbench window contains one or more perspectives. • A perspective defines the initial set and layout of views in the Workbench window. Within the window, each perspective shares the same set of editors.
Perspectives • Perspectives show all functionality associated with a large task, for example the Java Perspective is associated with creating a Java application, while the Debug perspective contains the views that you would use while debugging Java programs. • Each perspective has a default layout with views and editors appropriate for that task. If the views and editors are moved within a perspective, Eclipse will remember the new layout.
Perspectives • Opening a Perspective A perspective is opened by selecting Window > Open Perspective.. > Other.. for a complete list of perspectives, or the icon can be selected in the tab located in the upper right of the screen. In Eclipse there are 8 perspectives, but other perspectives may be listed when plug-ins are added. A description of the 8 perspectives are listed below:
Perspectives • 5.1.1 CVS Repository Exploring : provides tools for the user to connect to and explore a CVS repository. • 5.1.2 Debug : provides tools for the user to create breakpoints in code, and step through the code to view values of variables at a given point in time in order to debug mistakes in the code base. • 5.1.3 Java : provides tools for the user to easily create and explore a Java project • 5.1.4 Java Browsing : provides tools for the user to quickly move between Java projects, packages, types, and members of all Java projects open in the workbench. • 5.1.5 Java Type Hierarchy : provides tools for the user to quickly view the Java type hierarchy of files in a Java project • 5.1.6 Plug-in Development : provides tools for a user to create an Eclipse plug-in • 5.1.7 Resource : provides general editing tools for the user to create a basic project. This is the default perspective. • 5.1.8 Team Synchronizing : provides tools for teams to synchronize their code base through a CVS repository or other means.
Perspectives • Extra way to open a Perspective • You can use the General > Perspectives preference page to open perspectives in the same window or in a new window. How? Click Window > Preference > General > Perspectives
Perspectives • Views in a Perspective • Each perspective has a default layout of views that are most commonly used for the task that the perspective supports; however, each perspective has other views that may provide helpful functionality to the perspective.
Perspectives • Switching Between Perspectives • All perspectives that have been opened, remain easily accessible through the perspective tab at the upper right of the workbench. A user can change perspective by clicking on the icon associated with the perspective they wish to change too.
Perspectives • Closing Perspectives • To close a perspective, right click on the icon associated with the perspective that you wish to close and select Close from the context menu.
Editors and Views • Eclipse has two main components for displaying information about a project. • These are: • editors, and • views.
Editors • Editors are a way for a user to change information in a project. An editor may contain text or objects that can be changed and manipulated, but usually editors contain the code being developed during a project (such as .java files). A different editor may be opened depending on the file type selected. The editor or application that is opened when a file is selected can be modified in Window > Preferences > General > Editors > File Associations
Views • Views show a representation of a single task in the Eclipse environment. For example the Navigator view shows the hierarchal file structure of every project open in the Eclipse workbench, and allows a file to be opened. Any number of views can be opened in the workbench at one time. To open a view that is not displayed in the workbench select • Window > Show View.. > Other.. for a complete list of views.
Moving Editors and Views • Editors and Views can be moved around on the workbench to create a custom layout. To move an editor or a view, select the tab with the name of the file or view being moved. If you can add the file or view to a stack of files or views an icon is displayed. If you can move the file or view beside an editor or view a black arrow is shown with the new location of the file or view outlined in the workspace. A view may not be stacked in an editor location and an editor may not be stacked in a view location.
Starting Eclipse • :
Starting Eclipse • Eclipse creates applications exploring projects. • Eclipse stores projects in a folder called a workspace. • A dialog box opens asking user to choose a workspace folder to use for the current session.
Getting Started Using Eclipse • Source: • Eclipse Kepler, • Help >Welcome, • Start page, • Tutorials, • Create a Hello World application
Create a Hello World application • It is a 5 steps process:
Create a Hello World application • Open the Java perspective: • In the main menu select • Window > Open Perspective > Java • Window > • Open Perspective > • Java
Create a Hello World application • Create a Java project: • Before creating a class, we need a project to put it in. In the main toolbar, click on the New Java Project button. Enter HelloWorld for the project name, then click Finish.
Create a Hello World application • Create your HelloWorld class: • The next step is to create a new class. In the main toolbar again, click on the New Java Class button. If not already specified, select HelloWorld/src as the source folder. Enter HelloWorld for the class name, select the checkbox to create the main() method, then click Finish. • The Java editor will automatically open showing your new class.
Create a Hello World application • Add a print statement: • Now that you have your HelloWorld class, in the main() method, add the following statement: System.out.println("Hello world!"); • Then save your changes; the class will automatically compile upon saving.
Create a Hello World application • Run your Java application: • To run your application, right-click on your class in the Package Explorer and select Run As > Java Application. • The Console view should appear at the bottom and display the "Hello, world!" output.
Creating a Java Project There are four ways to create a Java project: 6.1.1 Select File > New > Project 6.1.2 Click the black arrow of the left most button of the Icons tool bar. Select Project, 6.1.3 Right click on the Package Explorer view in the Java Perspective, then click New and select Project. 6.1.4 Click the leftmost icon on the Icons tool bar.
Creating a Java Project 6.3 Give the project a name. If you would like to create src and bin folders for your source and class files respectively select the Create separate source and output folders radio button under the Project layout area of the New Java Project dialog. The default source folder is src/ and the default output folder is bin/. You can change these defaults by clicking on the Configure default... link. Click the Next button.
Creating a Java Project 6.4 The next screen has four tabs: Source, Projects, Libraries, Order and Export.