Eclipse IDE Tutorial. To start Eclipse, double-click on the bestthing.info (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.
|Language:||English, Indonesian, Arabic|
|ePub File Size:||20.51 MB|
|PDF File Size:||18.15 MB|
|Distribution:||Free* [*Sign up for free]|
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.
Some user prefer a dark styled IDE. The appearance of Eclipse can be configured. By default, Eclipse ships with a few themes but Eclipse also provides a dark theme. The Theme selection allows you to switch to the Dark theme of Eclipse.
Workspace The workspace is the physical location file path you are storing certain meta-data and optional your development artifacts.
Your projects, source files, images and other artifacts can be stored inside or outside your workspace. The meta-data stored for the workspace contains preferences settings, plug-in specific meta data, logs etc.
You typically use different workspaces if you require different settings or if you want to divide your work. It is not mandatory that a project resides within the workspace directory. It is possible to refer to external resources e. Views and editors Eclipse provides views and editors to navigate and change content. View and editors can be grouped into perspectives.
A view is typically used to work on a set of data. This data might be a hierarchical structure.
If data is changed via the view, the underlying data is directly changed, without the need to save. For example, the Project Explorer view allows you to browse and modify files of Eclipse projects. Any change in the Project Explorer is directly applied to the files, e. Editors are typically used to modify a single data element, e.
Change in an editor are only applied once the user saves. For example, the Java editor is used to modify Java source files. Changes to the source file are applied once the user selects the Save button. A editor with changed data a dirty editor is marked with an asterisk left to the name of the modified file. Eclipse projects An Eclipse project contains source, configuration and binary files related to a certain task. It used to be one large release per year but in this was changed to one release every three months.
Every year a larger releases is done, which gets a new release number and a new release name. The EPL is designed to be business-friendly. EPL licensed programs can be used, modified, copied and distributed free of charge. The consumer of EPL-licensed software can choose to use this software in closed source programs. This can for example be done by filling a bug report at the public Eclipse bug tracker and by uploading a Gerrit change.
The Eclipse Foundation validates that source code contributed to Eclipse projects is free of intellectual property IP issues.
This process is known as IP cleansing. Contributions with more than lines of code require the creation of a Contribution Questionnaire, and a review and approval by the IP team. The Eclipse IDE can be extended with additional software components. Eclipse calls these software components plug-ins.
Plug-in can be grouped into features. Several pre-packaged Eclipse distributions are available for download. The Eclipse project has a simultaneous release every year at the end of June.
In June the Eclipse 4. This is called the Eclipse SDK. You find Stable Builds which are tested by the community. These milestone ending with M and a number and release candidate RC builds are created based on a predefined time schedule. Integration I and Nightly N builds are test builds which are automatically created.
They are not manually tested. In general, milestone and RC builds are relative stable compared to integration builds, but may not contain the latest features and patches. You find one of latest Eclipse SDK builds under the http: The packaged solutions are also available as developer release. You find them by clicking on the Developer Builds tab from the Eclipse download page.
The Eclipse IDE consists of several components. The Eclipse. It contains typical required packages, like support for the Maven and Gradle build system and support for the Git version control system. The following screenshot shows the Eclipse download website for a Linux system. Press on the link beside the package description, for example Linux Bit to start the download. The links which are displayed depend on your operating system.
Most operating systems can extract zip or tar. But if in doubt, google for "How to extract a zip or tar. It is recommended to extract Eclipse into a directory with no spaces in its path. Do not use mapped network drives as access to them is slow. Also avoid to have path names longer than characters, as earlier Windows version had problems with long path names.
After you extracted the compressed file you can start Eclipse. No additional installation procedure is required, assuming that you Java installed on your machine. To start Eclipse, double-click the eclipse. If Eclipse does not start, check your Java version. The Eclipse system prompts you for a workspace. The workspace is the location in your file system where Eclipse stores its preferences and other resources.
For example, your projects can be stored in the workspace. Eclipse starts and shows the Welcome page. Close this page by clicking the x beside Welcome. After closing the welcome screen, the application should look similar to the following screenshot. Some user prefer a dark styled IDE. The appearance of Eclipse can be configured. By default, Eclipse ships with a few themes but Eclipse also provides a dark theme. The workspace is the physical location file path you are storing certain meta-data and optional your development artifacts.
Your projects, source files, images and other artifacts can be stored inside or outside your workspace. The meta-data stored for the workspace contains preferences settings, plug-in specific meta data, logs etc.
You typically use different workspaces if you require different settings or if you want to divide your work. It is not mandatory that a project resides within the workspace directory. It is possible to refer to external resources e. Eclipse provides views and editors to navigate and change content.
View and editors can be grouped into perspectives. A view is typically used to work on a set of data. This data might be a hierarchical structure. If data is changed via the view, the underlying data is directly changed, without the need to save. For example, the Project Explorer view allows you to browse and modify files of Eclipse projects.
Any change in the Project Explorer is directly applied to the files, e. Editors are typically used to modify a single data element, e.
Change in an editor are only applied once the user saves. For example, the Java editor is used to modify Java source files. Changes to the source file are applied once the user selects the Save button. A editor with changed data a dirty editor is marked with an asterisk left to the name of the modified file.
An Eclipse project contains source, configuration and binary files related to a certain task. It groups them into buildable and reusable units. An Eclipse project can have natures assigned to it which describe the purpose of this project. For example, the Java nature defines a project as Java project.
Projects can have multiple natures combined to model different technical aspects. Natures for a project are defined via the. The application toolbar contains actions which you typically perform, e.
It also allows you to switch between perspectives. Eclipse provides different perspectives for different tasks. For Java development you usually use the Java Perspective , but Eclipse has much more predefined perspectives, e. Open editors are typically shared between perspectives, i.
The main perspectives used for Java development are the Java perspective and the Debug perspective. On the left hand side, this perspective shows the Package Explorer view, which allows you to browse your projects and to select the components you want to open in an editor via a double-click. For example, to open a Java source file, open the tree under src , select the corresponding.
This will open the file in the default Java editor. The following picture shows the default Java perspective. The Package Explorer view is on the left. In the middle you see the open editors. Several editors are stacked in the same container and you can switch between them by clicking on the corresponding tab. Via drag and drop you can move an editor to a new position in the Eclipse IDE.
To the right and below the editor area you find more views which were considered useful by the developer of the perspective. For example, the Javadoc view shows the Javadoc of the selected class or method. A common problem is that you changed the arrangement of views and editors in your perspective and you want to restore its original state.
For example, you might have closed a view. You can change the layout and content within a perspective by opening or closing parts and by re-arranging them. This opens the Show View dialog which allows you to search for certain parts. For example, you can hide or show toolbar and menu entries. The Package Explorer view allows you to browse the structure of your projects and to open files in an editor via a double-click on the file.
It is also used to change the structure of your project. For example, you can rename files or move files and folders via drag and drop. A right-click on a file or folder shows you the available options. The Problems view shows errors and warning messages. Sooner or later you will run into problems with your code or your project setup. To view the problems in your project, you can use the Problems view which is part of the standard Java perspective.
The messages which are displayed in the Problems view can be configured via the drop-down menu of the view. For example, to display the problems from the currently selected project, select Configure Contents and set the Scope to On any element in the same project. The Problems view also allows you to trigger a Quick fix via a right mouse-click on several selected messages. See chapter Quick Fix for details on the Quick fix functionality. The Javadoc view shows the documentation of the selected element in the Java editor.
The Java editor is used to modify the Java source code. Each Java source file is opened in a separate editor. If you click in the left column of the editor, you can configure its properties, for example, that line number should be displayed.
The following section describes how to create a minimal Java application using Eclipse. It is tradition in the programming world to create a small program which writes "Hello World" to the console.
We will adapt this tradition and will write "Hello Eclipse! This tutorial uses the naming convention that the project is named the same as the top-level package in the project.
Enter com. Reverse domain names should be used for project and packages names to prevent name clashes. For example, is relatively unlikely that another company uses the com. A new project is created and displayed as a folder. Open the com. A good naming convention is to use the same name for the top level package and the project. For example, if you name your project com.
Create the com. If necessary adjust the name of your new package in the dialog and press the Finish button. Enter MyFirstClass as the class name and select the public static void main String args checkbox.
This creates a new file and opens the Java editor. Change the class based on the following listing. You could also directly create new packages via this dialog. If you enter a new package in this dialog, it is created automatically.
Now run your code. You created your first Java project, a package, a Java class and you ran this program inside Eclipse. A JAR file is the standard distribution format for Java applications. Select JAR file and select the Next button. Select your project and enter the export destination and a name for the JAR file, for example myprogram.
Press The Finish button.
Step 4: How to import files into an Eclipse Project
This creates a JAR file in your selected output directory. Open a command shell, e. This should open a console window. Switch to the directory which contains the JAR file, by typing cd path. For example, if your JAR is located in c: To run this program, include the JAR file in your classpath. The classpath defines which Java classes are available to the Java runtime.
You can add a JAR file to the classpath with the -classpath option. Type the above command in the directory you used for the export and you see the "Hello Eclipse! This is a simple class without the usage of any unit testing framework like JUnit. The Eclipse editor should mark the created class with an error because the required import statements are missing.
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.
Other options such as Link With Editor are available. The Central part of the workbench is the placeholder for file Editors. You can type in a keyword and see all possible related actions. This platform is extremely extensible. So the Eclipse IDE is only the beginning of what you can do—many extensions for it are available from multiple sources. A number of Eclipse projects conforming to some quality commitment are aggregated in a single extension repository that you can access directly from your IDE.
You should get a source called Neon or Oxygen Eclipse Marketplace http: Some extensions are not in the Marketplace. Those extensions usually provide a URL that references an update-site, or p2 repository p2 is the package manager for Eclipse plugins.
See https: Then you can browse available preferences. Changing preferences there apply to the whole workspace. You can edit the shortcuts or switch between different schemes. For example, an Emacs keybinding is available out-of-the-box, and some extensions provide other bindings, such as a Vim-based binding.
The default Eclipse IDE theme is a light one, but a dark one is provided if you prefer. Something that can also be convenient to configure, mainly for accessibility purposes, are the fonts and colors used by the IDE. If you feel creative, a Marketplace extension called Jeeeyul's Eclipse Themes adds some more colorful themes for the Eclipse IDE and allows you to customize themes in more detail.
Projects have specific preferences. This allows to configure things such as Code-Style, some automatic refactorings, or other useful operations to trigger when saving a file. Project Properties also allow you to configure validation, compilation, and everything else for controlling your project behavior in Eclipse. Learn some good shortcuts. As explained above, you can see and change these via the Preferences. Eclipse lets you create a large variety of projects and files.
The actual list depends on which extensions are installed. So if you want to create a project for some technology, make sure the necessary extensions are installed in order to have the best New Wizard possible.
Those 2 entry-points should lead you to every SCM option possible. The Team context menu offers all useful operation such as git add , git reset -- , git blame , and more.
AEM Developer Tools for Eclipse
This wizard will take the location you want to work with and will run some analysis to find a good configuration for the project to take advantage of the relevant IDE features. Eclipse also provides some wizards dedicated to specific project types.
The 3 main ones for Java development are. Once your Java Project is created, you can right-click on it to perform many operations, such as creating a new class, a new interface, a new JUnit test, or some specific classes Beans, Jax-RS for certain projects. From there you can tweak many things, such as error reporting, classpath, Java compliance, and more.
This enables various analyzers on the project and reports errors and problems directly in the code. Eclipse usually provides resolutions for the errors it reports. The severity of most problems can be configured in the Project Properties. Some Eclipse extensions such as the FindBugs plugin can provide additional error reporting to improve the quality of your code.
Try to fix all issues reported in that view for good productivity and good code quality. Eclipse comes with a lot of refactoring and other advanced editing operations. The available operations depend on the current selection. Examples of the most useful refactorings include: The Run As context-menu on a Java element is populated by what seems to be the best Run Configurations for your current selection.
Just select one and it will run it. Customizing a Run Configuration allows to more easily set additional System Properties, Environment Variables, Java settings, etc, that will be used at runtime.
Once you have a Run Configuration ready, it is stored and can be run as many times as you want.
Speech-Enablement of Eclipse IDE and Eclipse Rich Client Applications Using AspectJ
Once you have configured a server in the Servers view, you can use it to easily re-deploy your application to the server, usually without requiring for a restart. Debugging in Eclipse is just another flavor of running the application as documented above. The difference is that we now talk about Debug Configurations which are just like Run Configurations, but with debug enabled. An interesting Debug Configuration provides the ability to connect debugger to an external Java application.
To do so, make sure your application to debug is started with the debug flags, usually -agentlib: Manage breakpoints enablement, grouping A powerful feature is Conditional Breakpoints.
Most of those views are visible by default in the Debug perspective, that will be recommended when Eclipse the debugger notices the target application is suspended by a breakpoint or an error. Eclipse comes with an integration with JUnit. The test report will be shown in a dedicated view that shows a clear status of your tests, and allowing to do advanced filtering, to navigate inside your production code and to compare expected and actual results.Code Formatter Eclipse allows you also to specify the settings for formatting the source code.
This section demonstrates the quick fix for converting anonymous inner classes to lambda expressions. Eclipse update manager The Eclipse IDE contains a software component called Update Manager which allows you to install and update software components.
Free use of the software examples is granted under the terms of the Eclipse Public License 2. To add a plug-in to your Eclipse installation, put the plug-in. Gives magic numbers or hard-coded strings a descriptive constant name and replaces all occurences. During the export the user can select which components should be included into this description file.