Eclipse IDE Tutorial. To start Eclipse, double-click on the (Microsoft Windows) or eclipse (Linux / Mac) file in the directory where you unpacked. which is both the leading Java™ integrated development environment (IDE) and the the Eclipse Platform contains the functionality required to build an IDE. Eclipse IDE Keybindings. General. Ctrl+3. +3. Go to quick access search for available views, actions, wizards, menus and more. Alt+ +Q Q. + +Q Q.

Eclipse Ide Pdf

Language:English, Arabic, French
Published (Last):17.05.2016
ePub File Size:15.40 MB
PDF File Size:18.60 MB
Distribution:Free* [*Register to download]
Uploaded by: MALIK

Ganymede) of the Eclipse IDE for Java. Developers has been installed on GL. – From any of the Linux machines in the labs simply run the command eclipse. Java application development is supported by many different tools. One of the most powerful and helpful tool is the free Eclipse IDE (IDE = Integrated. This tutorial will teach you how to use Eclipse in your dayday life while We assume you are going to use Eclipse IDE to handle all levels of Java projects.

Note that alternatively you can download an archive instead of using the installation link. This allows offline installation but you will miss automatic update notifications this way.

In Eclipse, open the Help menu. Click Install New Software. In Location copy the installation URL. Click Ok. Check both AEM and Sling plugins. Click Next. Accept the lincese agreements and click Finish. Click Yes in order to restart Eclipse. Learn more about the Project Archetype. This step might take a while since m2eclipse needs to scan the archetype catalogs.

Choose com. Fill in a Name, Group id and an Artifact id for the sample project. You can also opt to set some advanced properties. This should remove the syntax error. Finish the implementation for the Tester class based on the following code. Finish the source code and calculate the correct values. Run the Tester class and validate that your implementation is correct. The Tester class checks for an example value but the method should work for different input values.

You can export and import Eclipse projects. This allows you to share projects with other people and to import existing projects.

You can import from an archive file, i. Export your one of your projects into a zip file. Switch into a new workspace and import the project into your new workspace based on the zip file you exported. The primary way of navigating through your project is the Package Explorer or alternatively the Project Explorer view. You can open nodes in the tree and open a file in an editor by double-clicking on the corresponding entry in the tree hierarchy. The drop-down menu in the Package Explorer allows you to filter the resources which should be displayed or hidden.

The Package Explorer view allows you to display the associated file from the currently selected editor. For example, if you are working on the Foo. To activate this behavior, press the Link with Editor button in the Package explorer view as depicted in the following screenshot. You can navigate between the classes in your project via the Package Explorer view as described before.

You can navigate the tree and open a file via a double-click. In addition, you can open any class by positioning the cursor on the class in an editor and pressing F3. This shows the following dialog in which you can enter the class name to open it.

You can also search for package names. Each part of the package name must end with a.

You can open any file from your open projects via the Open Resource dialog. This dialog allows to enter the file name and to open or show it in a selected view. The following screenshot demonstrate the usage to open a pom. Quick Outline shows you an structured overview of the file you are editing. For example, for a Java class you see its methods with the option to filter. You can also reach this option, via right-click in an editor via the Quick Outline option. By default, Quick Outline shows only the direct members and fields of the Java class.

The default look of the Quick Outline option is similar to the Quick Outline view of the Java perspective. The type hierarchy of a class shows you which classes it extends and which interfaces it implements. You can use the type hierarchy to navigate to one of these elements. To open the type hierarchy of the selected class, right-click in the editor and select Open Type Hierarchy Shortcut: F4 or Quick Type Hierarchy Shortcut: You frequently need to find files containing certain text or other meta data.

Use the File Search tab to search for text with the option to use regular expressions and also to replace matching entries. Eclipse associates file extensions with the default tab. You can customize the available search tabs via the Customize button in the Search dialog. Via the Remember the last used page you can configure Eclipse to use your last tab as default. For example, use the Java Search tab to search for Java elements, e.

The Search view shows the search results for the selected scope. You can double-click on a search entry to navigate to the corresponding position in the editor.

The currently selected search result is also indicated via an arrow in the left border of the editor. This allows you to search in the current active editor for a text which is displayed in the status line as depicted by the following screenshot. The advantage of this search is that no pop-up dialog is opened which blocks other elements in the Eclipse IDE. You can also navigate via the annotation buttons, e. By pressing the buttons you can navigate to the related annotations.

The following screenshot shows source code with two warnings and one error and you can navigate between the corresponding code via the annotation buttons.

Which annotations are relevant for navigation can be configured via the drop-down menu of the toolbar. This selection is highlighted in the following screenshot.

In a lot of cases you can also use the mouse to navigate to or into an element if you press the Ctrl key. For example, press the Ctrl key and left click with the mouse on the name of a class to jump into the class declaration. Similar to the left mouse click combined with the Ctrl , you can use the F3 key to go into a class.

You can also activate the breadcrumb mode for the Java editor which allows you to navigate the source code directly from the Java editor.

You can activate this mode via right-click in the editor and by selecting the Show in Breadcrumb entry. This allows you to navigate the source code from the editor as depicted in the following screenshot.


There are a lot of shortcuts available for navigation. Closing projects saves memory in Eclipse and can reduce the build time. Eclipse ignores closed projects, e. Also the Problems view does only shows errors of opened projects.

This typically helps you focus your attention on the project. You can close projects via a right-click on it and by selecting the Close Project menu entry. Alternatively, if you work on a project, you can close all unrelated projects via a right-click on it and by selecting the Close Unrelated Projects menu entry. You can use the filter functionality for the Package Explorer view to hide the closed projects. Content assist is a functionality in Eclipse which allows the developer to get context-sensitive code completion in an editor upon user request.

This will replace syso with System. If you have a reference to an object, for example, the object person of the type Person and need to see its methods, type person. Whenever Eclipse detects a problem, it will underline the problematic text in the editor. This functionality is called Quick Fix.

Eclipse will suggest creating a field or local variable. Quick Fix is extremely powerful. For example, it allows you to create new local variables and fields as well as new methods and new classes.

It can also assign a statement to a variable and much more.

Quick Fix also gives several options for code changes on code which does not contain errors, e. You can use content assists, quick fixes and refactoring for Java 8. This section demonstrates the quick fix for converting anonymous inner classes to lambda expressions. Eclipse has several possibilities to generate code for you.

This can save significant time during development. For example, Eclipse can override methods from superclasses and generate the toString , hashcode and equals methods. It can also generate getter and setter methods for attributes of your Java class. To test the source generation, create the following class in your com. In this exercise you practice the usage of code generation and the usage of the Content Assists functionality.

Use Eclipse to generate a toString method for the Todo class based on the id and summary field. Also generate a hashCode and equals method based on the id field. Create a new class called TodoProvider. Create the following static method in your TodoProvider class.

Write another TodoProviderTest class with a public static void main String[] args method. In your main method call the createInitialModel method and validate that the returned number of items is 5. If another number than 5 is returned, throw a RuntimeException. If the correct number is returned, write the String "Correct" to the Console view. Use Content assist to create the System.

While this exercise was about code generation and content assists, you might be interested in a potential solution for this exercise. The following listing contains a potential solution. This section covers the refactoring facilities of Eclipse which allow you to improve the structure of your source code. Refactoring is the process of restructuring the code without changing its behavior. For example, renaming a Java class or method is a refactoring activity.

Eclipse will make sure that all calls in your Workspace to your class or method are renamed. The following screenshot shows how to call the Rename refactoring for a class. The cursor is positioned on the class and the context menu is activated via a right-click on the class.

Gives magic numbers or hard-coded strings a descriptive constant name and replaces all occurences. Eclipse has many more refactorings. The available options depend on the selection in the Java editor. In most cases you should get an idea of the performed action by the naming of the refactoring operation. A useful refactoring is to mark code and create a method from the selected code.

Use calculateSum as the name of the new method. You can also extract strings and create constants based on the strings. Mark for this example the "Hello Eclipse!

Eclipse provides a lot of shortcuts to work efficiently with the IDE. For a list of the most important Eclipse shortcuts please see https: You can store JAR files directly in your project, and add them to the classpath which the Java compiler of Eclipse is using. To manage the classpath for your Eclipse, right-click on your project and select Properties.

JAR files can be stored outside your project or inside. Select the Java library you want to import and select the folder, e. Alternatively, to the import approach via the menu, you can copy and paste the jar file into a folder. You can define in Eclipse that a project is dependent on another project. If you do this, you can use its classes in the project defining the dependency. To do this select your project, right-click on it and select Properties. Select Java Build Path and the Projects tab.

This only works within Eclipse, it allows you to develop several projects which will later be exported as JAR files together. Outside of Eclipse you need to create Java libraries for the projects and add them to the classpath.

You can open any class by positioning the cursor on the class in an editor and pressing F3. This shows a dialog in which you can enter the class name to open it. This happens, for example, if you open a class from a the standard Java library without attaching the source code to it.

To see the source code of such a class, you can attach a source archive or source folder to a Java library. Afterwards, the editor shows the source instead of the bytecode. The following screenshot shows this setting for the standard Java library.

The file is typically called src. It is also possible to add Javadoc to a library which you use. For this you need to have the Javadoc somewhere in your filesystem. The Eclipse IDE contains a software component called Update Manager which allows you to install and update software components. Installable software components are features or plug-ins. These features are located in update sites or software sites.

An update site contains installable software components and additional configuration files. It can be located in various places, e.

The configuration files provide aggregated information about the software components in the update site. The update functionality in Eclipse uses this information to determine which software components are available in which version. This allows the Eclipse update functionality to download only components which are new or updated.

The system searches for updates of the already installed software components. If it finds updated components, it will ask you to approve the update. From the Work with list, select or enter a URL from which you would like to install new software components. If you select a valid update site, Eclipse allows you to install the available components.

Check the components which you want to install. If they are not categorized, they will not be displayed, unless the grouping is disabled. After an update or an installation of a new software component, you should restart Eclipse to make sure that the changes are applied. Eclipse also contains a client which allows installing software components from the Eclipse Marketplace client. The advantage of this client is that you can search for components, discover popular extensions and see descriptions and ratings.

Compared to the update manager, you do not have to know the URL for the software site which contains the installable software components. Most Eclipse distributions contain the Marketplace client by default. You may need to install the Marketplace client software component into Eclipse before you can use it.

You can use the Find box to search for components. Pressing the Install button starts the installation process. The marketplace client allows to install your favorite plug-ins directy. For this, go to the Eclipse Marketplace website and login with your Eclipse. Afterwards, select the Favorites tab in the Eclipse Marketplace client and login to be able to install your favorites.

Eclipse plug-ins are distributed as jar files. If you want to use an Eclipse plug-in directly or do not know the update site for it, you can place it in the dropins folder of your Eclipse installation directory. Eclipse monitors this directory and during a re- start of your IDE, the Eclipse update manager installs and removes plug-in based on the files contained in this directory. You should not modify the content of the Eclipse plugins directory directly. If you want to install plug-ins, put them into the dropins folder.

If you want to remove it, delete the JAR from this folder. Plug-ins are typically distributed as jar files. To add a plug-in to your Eclipse installation, put the plug-in. Eclipse should detect the new plug-in and install it for you. If you remove plug-ins from the dropins folder and restart Eclipse, these plug-ins are automatically removed from your Eclipse installation. Eclipse allows you to export a file which describes the installed Eclipse components.

During the export the user can select which components should be included into this description file. Other users can import this description file into their Eclipse installation and install the components based on this file. Select the components which should be included in your description file.

The wizard allows you to specify the components which should be installed. The Eclipse update manager has a component called director which allows you to install new features via the command line. You need to start this command in the command line and it assumes that you are in a directory which contains your Eclipse installation in a folder called eclipse. The feature names which you need for this operation can be seen on the second page of the standard installation dialog of the Eclipse update manager.

The behavior of the Eclipse IDE can be controlled via key value pairs stores as preference settings. Each Eclipse software component can define such perferences and use the values to configure itself. This allows you for example to configure how long the Eclipse waits before the code completion or if the import statements in your source code should be automatically adjusted if you save your source code.

Which preferences are key values stored on the file system, the Eclipse IDE allows the user to configure most of these values via the preference dialog. You can use the filter box to search for specific settings. Correctly configuring Eclipse to your needs can largely improve your productivity. Most of these preference settings are specific to your workspace but some are also valid for all workspaces. In this file you enter default values for preference settings.

For example, the following will setup a default type filter for the java. The following example eclipse. To identify a key for a certain preference setting you can export existing preference settings via the following approach. The Eclipse IDE is relatively conservative configured to avoid surprises during development.

Main navigation

Certain settings in the Eclipse IDE allow you to use it more efficiently. If you find a setting in this exercise not working for you, you can always skip that setting. There is not a single correct setting for everyone in the world. You can synchronize the currently selected Java editor with the selection in the Project Explorer or the Package Explorer view. This gives you a clearer visibility which object you are currently editing. Eclipse can make typing more efficient by placing semicolons at the correct position in your source code.

In the Automatically insert at correct position selection enable the Semicolons checkbox. Afterwards, you can type a semicolon in the middle of your code and Eclipse positions it at the end of the current statement. Eclipse allows you to escape text automatically if it is pasted into a String literal. Eclipse would escape the text automatically for you. Now you can paste text that should be escaped.

The following code snippet shows an example for the resulting code if you paste HTML code containing a link into a string literal. You can configure Eclipse to highlight the matching brackets of a code block in the source code editor. Before the change you would not see the enclosing brackets.

Afterwards, they will be slightly highlighted. This helps to see in which block you are. By default, Eclipse determines if the currently selected file is executable and try to start that.

This is sometimes confusing. You can configure the Eclipse IDE to always start the last started program. To add import statements to your code, you can use the Organize Imports action shortcut: If there are several alternatives, Eclipse suggests all available packages and the user has to select the right one.

The Save Actions setting can automatically organize import statements. It adds import statements automatically if there is only one possible import and removes unused ones.

The following shows the available packages for the List class in the Organize Imports dialog. The setting in the following screenshot excludes the java.

Please note that Eclipse shows in its default configuration only the packages that are used in the current workspace. If you want to exclude standard Java packages, you have to create at least one Java project.

Eclipse can perform actions during the save operation shortcut: Select that the source code should be formated and that the imports should be organized at every save action. Import statements are only automatically created if where is one valid import.

If Eclipse determines more than one valid import, it will not add import statements automatically. You can improve this with Filtering out certain Java packages via Type filters , as this reduces the list of possible imports. You can also define the additional actions which are performed during save. Eclipse can override existing method calls, in case you trigger a code completion in an existing statement.

Eclipse can also try to guess the correct actual parameters for a method call. Due to Bug this setting is not usable at the moment.

The Eclipse IDE is configured to give you automatic code completion suggestion only after the. YOu can configure Eclipse to get code completion on every character. You can define how the Java compiler should react to certain common programming problems, e.

You can enable annotation-based null checks in Eclipse via the setting highlighted in the following screenshot. After enabling this setting, you can use the NonNull annotation on method parameters or variable definitions to indicate that these are not allowed to be NULL. Eclipse has the option to perform cleanup actions on existing code. This includes the removal of trailing whitespace, the additional of missing annotations but also advanced cleanups like the conversion of code to Java 8 lambda expressions.

After finishing the configuration, press OK and the Next button in the cleanup wizard to get a preview of the changes. This chapter lists other useful Eclipse settings which are not directly related to Java development. It also explains how to export and import your preference settings from one workspace to another.

The Default button in this preference dialog allows you to set the default editor for a certain file extension. This edit is used by default, if you open a new file with this extension. The other configured editors can be selected if you right-click on a file and by selecting Open With. In the sub-menu you see the available editors.

The available editors depend on your Eclipse installation. Eclipse remembers the last editor used to open a file. It uses this editor again the next time you open the file. Eclipse does allow you to export some preference settings separately, but for most of them you have to select the Export all flag.

You can also configure certain preference settings on a per project basis. To do this, select your project, right-click on it and select Properties. This creates a. You can add this folder to your version control system to ensure that every developer uses the same setting.

You could define a template which creates the method body for you. Eclipse allows you also to specify the settings for formatting the source code. These rules are used by Eclipse if you automatically format your source code. Press the New button to create a new set of formatting rules or press the Edit button to adjust an existing profile. This way you can ensure that everyone is using the same formatter while working on this project.

Eclipse can generate source code automatically. In several cases comments are added to the source code. In the code tree you have the templates. Select, for example, menu: Code [Method Body] and press the Edit button to edit this template and to remove the "todo" comment. Your Eclipse installation contains a file called eclipse.

For example, the -Xmx parameter can be used to define how large the Java heap size can get. The following listing shows an example eclipse. The parameters after -vmargs configure the Java virtual machine. On a modern machine with at least 8 Gigabyte available memory assigning MB or more to the Java virtual machine is a good practice to run Eclipse faster. You can in additional also turn of class verification in the JVM. This avoids that the JVM checks if the class data which are loaded is not corrupt or invalid.

To disable this check add the -Xverify: Eclipse allows you to configure it via startup parameters. This requires that you start Eclipse from the command line or that you configure your launcher links to include these parameters. Enables the display of the current workspace directory in the header of the running IDE. For example, if you want to start Eclipse under Microsoft Windows using the c: Eclipse keeps a local history of files which have changed.

Every time an editable file is saved, the Eclipse runtime updates the local history of that file and logs the changes that have been made. This local history can then be accessed and used to revert the file changes or to compare against a previous version. Eclipse opens the History view. You can replace files based on the local history. You will create more and more projects in your development career.

Therefore, the data in your workspace grows and it is hard to find the right information. The Eclipse IDE allows you to organize your project into working sets so that you can hide certain resources. On the next dialog select Resource , press the Next button.

Select the projects you would like to see and give it a name.

Step 4: How to import files into an Eclipse Project

You can now filter the displayed files in the Package Explorer based on the created working set. You can also use the working set to structure your projects in your workspace.

For this, select Working Sets from the context menu of the Package Explorer view. This indicates a task for Eclipse. You find those in the Task view of Eclipse.

Via double-clicking on the task, you can navigate to the corresponding code. Close the editor for the MyFirstClass class.

This will start a new window which shows you the help topics for your currently installed components. Eclipse online help. The online help is version-dependent and contains the help for all Eclipse projects of the simultaneous release. The Eclipse webpage also contains a list of relevant resources about Eclipse and Eclipse programming.

You find these resources under the following link: Eclipse resources and Eclipse corner wiki. Eclipse Plug-in and RCP tutorials. Due to the complexity and extensibility of Eclipse, you will need additional resources to help you solve your specific problems. Fortunately, the web contains several resources which can help you with your Eclipse problems.

Currently, the best places to find, ask and answer questions are the Eclipse forums and Stack Overflow. Try to stay polite with your postings, as the Eclipse community values polite behavior. The Eclipse forums offer several topic-specific forums in which you can post and answer questions.

To post or to answer questions in the Eclipse forums, you need a valid user account in the Eclipse bug tracker. Stack Overflow also requires a user account and its community is very active. Stack Overflow allows to tag questions with the relevant keyword, e.

Ensure that you search the forums and mailing lists for solutions for your problem. Somebody else might has asked the same question earlier and the answer is already available. If you encounter a problem with the Eclipse IDE or think about a potential improvement for it, you should report this to the Eclipse project. The Eclipse bug and feature tracker is using the open source Bugzilla project from Mozilla. In this system, you enter Eclipse error reports.

Online training

You can also request new features or improvements of existing features. This bug tracker can be found under Eclipse Bugzilla.

Here you can search for existing bugs and review them. To participate actively in the Eclipse bug tracker, you need to create a new account. This can be done by clicking the Create a New Account link. Once you have a user account, you can login to the Eclipse bug tracker. This allows you to comment on existing bugs and report new ones. The user data for the all Eclipse sites are the same, i. Only for the Gerrit access, different user data is used.

As example you can report bugs for the Eclipse platform via the following link: Bug report for the Eclipse platform. The Eclipse Bugzilla system allows you and the Eclipse committer to enter the bug priority. But overall, it is up to each project do decide how they handle bugs so some variation from project to project will occur. The following rules can be used as guideline.

The bug blocks development or testing of the build and no workaround is known. This is the default value for new bug reports. Implies some loss of functionality under specific circumstances, typically the correct setting unless one of the other levels fit. Represents a request for enhancement also for "major" features that would be really nice to have.

In this exercise you use the Bugzilla system to review some of the Eclipse platform bugs. No action is excepted from you, but if you find an updated bug, you should update the bug report and describe that the problem is solved.

This exercise uses the Eclipse platform as example but you can use any Eclipse project of your choice. Open to Eclipse Bugzilla and select the Search button. In most cases Eclipse project have tons of unsolved bugs. If you are looking for existing software bugs, it is recommended to look at the latest bugs, e. To learn how to debug Eclipse Java programs, you can use https: To learn Java Web development, you can use with https: You can also extend Eclipse with https:Alternatively, if you work on a project, you can close all unrelated projects via a right-click on it and by selecting the Close Unrelated Projects menu entry.

This chapter lists other useful Eclipse settings which are not directly related to Java development. You can also navigate via the annotation buttons, e. You have the Eclipse Marketplace Client mpc. Once the Finish button is pressed, the JavaScript project will be created and available in the Project Explorer view.

SDK tools can also help set up and test applications. Mouse and keyboard navigation In a lot of cases you can also use the mouse to navigate to or into an element if you press the Ctrl key. Use the screenshot below to enter the correct values. Switch into a new workspace and import the project into your new workspace based on the zip file you exported.

Eclipse Node.

LAUREN from Naperville
Look over my other posts. I have always been a very creative person and find it relaxing to indulge in skeet shooting. I do relish reading comics yesterday.