| An introduction to application development tools in Red Hat Enterprise Linux 6Edition 2 Red Hat Subject Matter ExpertsRoland GrunbergEclipse and Eclipse plug-ins Red Hat Engineering Tools Development [email protected] Aldy HernandezCompiling and Building Red Hat Engineering Tools Development [email protected] Jeff JohnstonEclipse and Eclipse plug-ins Red Hat Engineering Tools Development [email protected] Benjamin KosnikLibraries and Runtime Support Red Hat Engineering Tools Development [email protected] Alex KurtakovEclipse and Eclipse plug-ins Red Hat Engineering Tools Development [email protected] Charley WangEclipse and Eclipse plug-ins Red Hat Engineering Tools Development [email protected] Development CommunityLegal NoticeCopyright © 2012 Red Hat, Inc. and others. The text of and illustrations in this document are licensed by Red Hat under a Creative Commons Attribution-Share Alike 3.0 Unported license ("CC-BY-SA"). An explanation of CC-BY-SA is available at http://creativecommons.org/licenses/by-sa/3.0/. In accordance with CC-BY-SA, if you distribute this document or an adaptation of it, you must provide the URL for the original version. Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert, Section 4d of CC-BY-SA to the fullest extent permitted by applicable law. Red Hat, Red Hat Enterprise Linux, the Shadowman logo, JBoss, MetaMatrix, Fedora, the Infinity Logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and other countries. Linux® is the registered trademark of Linus Torvalds in the United States and other countries. Java® is a registered trademark of Oracle and/or its affiliates. XFS® is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States and/or other countries. MySQL® is a registered trademark of MySQL AB in the United States, the European Union and other countries. All other trademarks are the property of their respective owners. 1801 Varsity Drive Raleigh, NC 27606-2072 USA Phone: +1 919 754 3700 Phone: 888 733 4281 Fax: +1 919 754 3701
Daftar IsiAbstract This document describes the different features and utilities that make Red Hat Enterprise Linux 6 an ideal enterprise platform for application development. It focuses on Eclipse as an end-to-end integrated development environment (IDE), but also includes command line tools and other utilities outside Eclipse. This book describes the some of the more commonly-used programming resources in Red Hat Enterprise Linux 6. Each phase of the application development process is described as a separate chapter, enumerating tools that accomplish different tasks for that particular phase. Note that this is not a comprehensive listing of all available development tools in Red Hat Enterprise Linux 6. In addition, each section herein does not contain detailed documentation of each tool. Rather, this book provides a brief overview of each tool, with a short description of updates to the tool in Red Hat Enterprise Linux 6 along with (more importantly) references to more detailed information. In addition, this book focuses on Eclipse as an end-to-end integrated development platform. This was done to highlight the Red Hat Enterprise Linux 6 version of Eclipse and several Eclipse plug-ins. This manual uses several conventions to highlight certain words and phrases and draw attention to specific pieces of information. In PDF and paper editions, this manual uses typefaces drawn from the Liberation Fonts set. The Liberation Fonts set is also used in HTML editions if the set is installed on your system. If not, alternative but equivalent typefaces are displayed. Note: Red Hat Enterprise Linux 5 and later includes the Liberation Fonts set by default. 1.1. Typographic ConventionsFour typographic conventions are used to call attention to specific words and phrases. These conventions, and the circumstances they apply to, are as follows. Mono-spaced Bold
Used to highlight system input, including shell commands, file names and paths. Also used to highlight keys and key combinations. For example: To see the contents of the file my_next_bestselling_novel in your current working directory, enter the cat my_next_bestselling_novel command at the shell prompt and press Enter to execute the command.
The above includes a file name, a shell command and a key, all presented in mono-spaced bold and all distinguishable thanks to context. Key combinations can be distinguished from an individual key by the plus sign that connects each part of a key combination. For example: Press Enter to execute the command. Press Ctrl+Alt+F2 to switch to a virtual terminal.
The first example highlights a particular key to press. The second example highlights a key combination: a set of three keys pressed simultaneously. If source code is discussed, class names, methods, functions, variable names and returned values mentioned within a paragraph will be presented as above, in mono-spaced bold . For example: File-related classes include filesystem for file systems, file for files, and dir for directories. Each class has its own associated set of permissions.
Proportional Bold This denotes words or phrases encountered on a system, including application names; dialog box text; labeled buttons; check-box and radio button labels; menu titles and sub-menu titles. For example: Choose ⤍ ⤍ from the main menu bar to launch Mouse Preferences. In the Buttons tab, click the Left-handed mouse check box and click Close to switch the primary mouse button from the left to the right (making the mouse suitable for use in the left hand). To insert a special character into a gedit file, choose ⤍ ⤍ from the main menu bar. Next, choose ⤍ from the Character Map menu bar, type the name of the character in the Search field and click Next. The character you sought will be highlighted in the Character Table. Double-click this highlighted character to place it in the Text to copy field and then click the Copy button. Now switch back to your document and choose ⤍ from the gedit menu bar.
The above text includes application names; system-wide menu names and items; application-specific menu names; and buttons and text found within a GUI interface, all presented in proportional bold and all distinguishable by context. Mono-spaced Bold Italic or Proportional Bold Italic
Whether mono-spaced bold or proportional bold, the addition of italics indicates replaceable or variable text. Italics denotes text you do not input literally or displayed text that changes depending on circumstance. For example: To connect to a remote machine using ssh, type ssh username @domain.name at a shell prompt. If the remote machine is example.com and your username on that machine is john, type ssh [email protected] . The mount -o remount file-system command remounts the named file system. For example, to remount the /home file system, the command is mount -o remount /home . To see the version of a currently installed package, use the rpm -q package command. It will return a result as follows: package-version-release .
Note the words in bold italics above - username, domain.name, file-system, package, version and release. Each word is a placeholder, either for text you enter when issuing a command or for text displayed by the system. Aside from standard usage for presenting the title of a work, italics denotes the first use of a new and important term. For example: Publican is a DocBook publishing system.
1.2. Pull-quote ConventionsTerminal output and source code listings are set off visually from the surrounding text. Output sent to a terminal is set in mono-spaced roman and presented thus: books Desktop documentation drafts mss photos stuff svnbooks_tests Desktop1 downloads images notes scripts svgs Source-code listings are also set in mono-spaced roman but add syntax highlighting as follows: package org.jboss.book.jca.ex1;import javax.naming.InitialContext;public class ExClient{ public static void main(String args[]) throws Exception { InitialContext iniCtx = new InitialContext(); Object ref = iniCtx.lookup("EchoBean"); EchoHome home = (EchoHome) ref; Echo echo = home.create(); System.out.println("Created Echo"); System.out.println("Echo.echo('Hello') = " + echo.echo("Hello")); }} Finally, we use three visual styles to draw attention to information that might otherwise be overlooked. Notes are tips, shortcuts or alternative approaches to the task at hand. Ignoring a note should have no negative consequences, but you might miss out on a trick that makes your life easier. Important boxes detail things that are easily missed: configuration changes that only apply to the current session, or services that need restarting before an update will apply. Ignoring a box labeled 'Important' will not cause data loss but may cause irritation and frustration. Warnings should not be ignored. Ignoring warnings will most likely cause data loss. 2. Getting Help and Giving FeedbackIf you experience difficulty with a procedure described in this documentation, visit the Red Hat Customer Portal at http://access.redhat.com. Through the customer portal, you can: search or browse through a knowledgebase of technical support articles about Red Hat products. submit a support case to Red Hat Global Support Services (GSS). access other product documentation.
Red Hat also hosts a large number of electronic mailing lists for discussion of Red Hat software and technology. You can find a list of publicly available mailing lists at https://www.redhat.com/mailman/listinfo. Click on the name of any mailing list to subscribe to that list or to access the list archives. If you find a typographical error in this manual, or if you have thought of a way to make this manual better, we would love to hear from you! Please submit a report in Bugzilla: http://bugzilla.redhat.com/ against the product Red_Hat_Enterprise_Linux.When submitting a bug report, be sure to mention the manual's identifier: doc-Developer_Guide If you have a suggestion for improving the documentation, try to be as specific as possible when describing it. If you have found an error, please include the section number and some of the surrounding text so we can find it easily. Chapter 1. Eclipse Development EnvironmentEclipse is a powerful development environment that provides tools for each phase of the development process. It is integrated into a single, fully configurable user interface for ease of use, featuring a pluggable architecture which allows for extension in a variety of ways. Eclipse integrates a variety of disparate tools into a unified environment to create a rich development experience. The Valgrind plug-in, for example, allows programmers to perform memory profiling (normally done through the command line) through the Eclipse user interface. This functionality is not exclusive only to Eclipse. Being a graphical application, Eclipse is a welcome alternative to developers who find the command line interface intimidating or difficult. In addition, Eclipse's built-in system provides extensive documentation for each integrated feature and tool. This greatly decreases the initial time investment required for new developers to become fluent in its use. The traditional (that is, mostly command line based) Linux tools suite (gcc , gdb , etc) and Eclipse offer two distinct approaches to programming. Most traditional Linux tools are far more flexible, subtle, and (in aggregate) more powerful than their Eclipse-based counterparts. These traditional Linux tools, on the other hand, are more difficult to master, and offer more capabilities than are required by most programmers or projects. Eclipse, by contrast, sacrifices some of these benefits in favor of an integrated environment, which in turn is suitable for users who prefer their tools accessible in a single, graphical interface. 1.1. Starting an Eclipse projectInstall eclipse with the following command: # yum install eclipse
Once installed, Eclipse can be started either by manually executing /usr/bin/eclipse or by using the system menu created. Eclipse stores all project and user files in a designated workspace. You can have multiple workspaces and can switch between each one on the fly. However, Eclipse will only be able to load projects from the current active workspace. To switch between active workspaces, navigate to > > . You can also add a new workspace through the wizard; to open this wizard, navigate to > > . For information about configuring workspaces, refer to Reference > Preferences > Workspace in the Workbench User Guide (). A project can be imported directly into Eclipse if it contains the necessary Eclipse metafiles. Eclipse uses these files to determine what kind of perspectives, tools, and other user interface configurations to implement. As such, when attempting to import a project that has never been used on Eclipse, it may be necessary to do so through the wizard instead of the wizard. Doing so will create the necessary Eclipse metafiles for the project, which you can also include when you commit the project. The wizard is suitable mostly for projects that were created or previously edited in Eclipse, that is, projects that contain the necessary Eclipse metafiles. 1.2. Eclipse User InterfaceEclipse features different perspectives. A perspective is a set of views and editors most useful to a specific type of task or project; the Eclipse workbench can contain one or more perspectives. Figure 1.4, "Eclipse User Interface (default)" features the default perspective for C/C++. Eclipse also divides many functions into several classes, housed inside distinct menu items. For example, the menu houses functions relating to compiling/building a project. The menu contains options for creating and customizing perspectives, menu items, and other user interface elements. For a brief overview of each main menu item, refer to ⤍ in the C/C++ Development User Guide or ⤍ in the Java Development User Guide. These are found in the Eclipse help. The following sections provide a high-level overview of the different elements visible in the default user interface of the Eclipse integrated development environment (IDE). The Eclipse workbench provides a user interface for many features and tools essential for every phase of the development process. This section provides an overview of Eclipse's primary user interface. The is used to write and edit source files. Eclipse can auto-detect and load an appropriate language editor (for example, C Editor for files ending in .c ) for most types of source files. To configure the settings for the Editor , navigate to > > > . The provides a hierarchical view of all project resources (binaries, source files, etc.). You can open, delete, or otherwise edit any files from this view. The View Menu button in the allows you to configure whether projects or working sets are the top-level items in the . A working set is a group of projects arbitrarily classified as a single set; working sets are handy in organizing related or linked projects. The window provides a condensed view of the code in a source file. It details different variables, functions, libraries, and other structural elements from the selected file in the , all of which are editor-specific. Some functions and plugged-in programs in Eclipse send their output to the view. This view's Display Selected Console button allows you to switch between different consoles. The view allows you to track specially-marked reminder comments in the code. This view shows the location of each task comment and allows you to sort them in several ways. Most Eclipse editors track comments marked with //FIXME or //TODO tags. Tracked comments-that is, task tags-are different for source files written in other languages. To add or configure task tags, navigate to > and use the keyword task tags to display the task tag configuration menus for specific editors/languages. Alternatively, you can also use > to open the task menu ( Figure 1.11, "Task Properties"). This will allow you to add a task to a specific location in a source file without using a task tag. The view displays any errors or warnings that occurred during the execution of specific actions such as builds, cleans, or profile runs. To display a suggested "quick fix" to a specific problem, select it and press Ctrl+1. 1.2.1. The Quick Access MenuOne of the most useful Eclipse tips is to use the menu. Typing a word in the menu will present a list of Views, Commands, Help files and other actions related to that word. To open this menu, press Ctrl+3. In Figure 1.13, "Quick Access Menu", clicking > will select the window. Click any item from the , , , or categories to run the selected item. This is similar to navigating to or clicking the respective menu options or taskbar icons. You can also navigate through the menu using the arrow keys. 1.2.2. Keyboard ShortcutsIt is also possible to view a complete list of all keyboard shortcut commands; to do so, press Shift+Ctrl+L. To configure Eclipse keyboard shortcuts, press Shift+Ctrl+L again while the list is open. 1.2.3. Customize PerspectiveTo customize the current perspective, navigate to > . This opens the menu, allowing the visible tool bars, main menu items, command groups, and shortcuts to be configured. The location of each view within the workbench can be customized by clicking on a view's title and dragging it to a desired location. The following figures display the other tabs in the : The tab configures what functions are visible in each main menu item. For a brief overview of each main menu item, refer to Reference > C/C++ Menubar in the C/C++ Development User Guide or Reference > Menus and Actions in the Java Development User Guide. Command groups add functions or options to the main menu or tool bar area. Use the tab to add or remove a Command group. The and fields display the functions or options added by the Command group to either Main Menu or Toolbar Area, respectively. The tab configures what menu items are available under the following submenus: 1.3. Editing C/C++ Source Code in EclipseRed Hat Enterprise Linux 6 provides Eclipse plug-ins for C/C++ development with the CDT. Specialized editors for C/C++ source code, makefiles, and GNU Autotools files are included. Functionality is also available for running and debugging programs. The Eclipse text editor supports most of the features expected in a text editor, such as cut, copy, paste, and block selection (Ctrl+Shift+A). It also has some relatively unique features, such as the ability to move a selection (Alt+Up/Down Arrow). Of particular interest to C/C++ programmers is the Content Assist feature. This feature presents a pop-up window with possible functions, variables, and templates for the current file/location. It is invoked by pressing Ctrl+Space while the cursor is at the desired location. The Eclipse C/C++ code editor also has error highlighting and refactoring. Code errors and warnings are annotated with colored wavy underlines. These errors and warnings may be present as code is entered into the editor, or they may be present only after a build has occurred and the compiler output has been transformed into these markers. The provided refactoring tools include the ability to rename code elements. This change can then be reflected in both uses and declarations of the function. The libhover plug-in for Eclipse provides plug-and-play hover help support for the GNU C Library and GNU C++ Standard Library. This allows developers to refer to existing documentation on glibc and libstdc++ libraries within the Eclipse IDE in a more seamless and convenient manner via hover help and code completion. For C++ library resources, libhover has to index the file using the CDT indexer. Indexing parses the given file in context of a build; the build context determines where header files come from and how types, macros, and similar items are resolved. To be able to index a C++ source file, libhover usually requires an actual build to be performed first, although in some cases it may already know where the header files are located. A C++ member function name is not enough information to look up its documentation so the libhover plug-in may require indexing for C++ sources. C++ allows different classes to have members of the same name, and even within a class, members may have the same name but with different method signatures. This requires the class name and parameter signature of the function to be provided to determine exactly which member is being referenced. In addition, C++ also has type definitions and templated classes. Such information requires parsing an entire file and its associated include files; libhover can only do this via indexing. C functions can be referenced in their documentation by name alone. As such, libhover does not have to index C source files in order to provide hover help or code completion. The appropriate header file include statement for a C library function can be automatically added if it is not already present. Select the C function in the file and use right-click > > to automatically add the required header files to the source. This can also be done using Shift+Ctrl+N. Hover help for all installed libhover libraries is enabled by default, and it can be disabled per project. To disable or enable hover help for a particular project, right-click the project name and click . On the menu that appears, navigate to > . Check or uncheck a library in the section to enable or disable hover help for that particular library. Disabling hover help from a particular library may be preferable, particularly if multiple libhover libraries overlap in functionality. For example, if a libhover plug-in for a C library were manually installed, such as the newlib C library (note that newlib C library plug-in is not provided in Red Hat Enterprise Linux 6). The hover help would contain C functions whos names overlap with those in the GNU C library (provided by default). A user would not want both of these hover helps active at once, so disabling one would be practical. When multiple libhover libraries are enabled and there exists a functional overlap between libraries, the Help content for the function from the first listed library in the section will appear in hover help (that is, in Figure 1.22, "Enabling/Disabling Hover Help", glibc ). For code completion, libhover will offer all possible alternatives from all enabled libhover libraries. To use hover help, hover the mouse over a function name or member function name in the . After a short time, no more than a few seconds, libhover will display library documentation on the selected C function or C++ member function. 1.4. Editing Java Source Code in EclipseRed Hat Enterprise Linux 6 provides Eclipse plug-ins for Java (Java SE) development with the JDT. Specialized editors for Java source code as well as for ant build.xml files are included. Functionality is also available for running and debugging programs. Eclipse provides a fully-featured interactive development environment for Java developers. Follow the same procedure to export an existing project, and when prompted for a location, enter the existing project's location instead. For more information regarding setting up a new Java project, refer to > > > > > . For an overview of these features, refer to > > > . The Debug Perspective, configured the first time the debugger is run, is a different layout that makes views related to debugging more prominent. For example, the view allows evaluation of Java expressions in the context of the current frame. The views that make up the Debug Perspective, like all views, are accessed through > and you do not have to be debugging to access these views. While debugging, hover over variables to view their values or use the view. Using the Debug view, it is possible to control the execution of programs and explore the various frames on the stack. For more information on debugging in the JDT, refer to > > > > > . 1.5. Eclipse RPM BuildingThe Specfile Editor Plug-in for Eclipse provides useful features to help developers manage .spec files. This plug-in allows users to leverage several Eclipse GUI features in editing .spec files, such as auto-completion, highlighting, file hyperlinks, and folding. In addition, the Specfile Editor Plug-in also integrates the rpmlint tool into the Eclipse interface. rpmlint is a command line tool that helps developers detect common RPM package errors. The richer visualization offered by the Eclipse interface helps developers quickly detect, view, and correct mistakes reported by rpmlint . The Eclipse .spec file editor plug-in also supports building RPM files from RPM projects. This feature can be used by employing an export wizard ( ⤍ ⤍ ) allowing the selection of whether a source RPM (src.rpm ), binary RPM, or both, are required. Build output is in the Eclipse Console view. For a limited number of build failures, there is hyperlinking support. That is, certain parts of the build failure are changed to be a hyperlink (Ctrl+Click) in the Eclipse Console view, which then points the user to the actual line in the .spec file that is causing the problem. Also of note is the wizard for importing source RPM (.src.rpm ) files, found in ⤍ ⤍ ). This allows the user to easily start with no configuration required, in case a source RPM has already been created. This project is then ready for editing the spec file and building (exporting) to source/binary RPMs. For further details, refer to the ⤍ section in the Specfile Editor User Guide in Help Contents. 1.6. Eclipse DocumentationEclipse features a comprehensive internal help library that covers nearly every facet of the Integrated Development Environment (IDE). Every Eclipse documentation plug-in installs its content to this library, where it is indexed. To access this library, use the menu. To open the main menu, navigate to > . The menu displays all the available content provided by installed documentation plug-ins in the field. The tabs at the bottom of the field provides different options for accessing Eclipse documentation. You can navigate through each "book" by section/header or by searching via the field. You can also bookmark sections in each book and access them through the tab. The Workbench User Guide documents all facets of the Eclipse user interface extensively. It contains very low-level information on the Eclipse workbench, perspectives, and different concepts useful in understanding how Eclipse works. The Workbench User Guide is an ideal resource for users with little to intermediate experience with Eclipse or IDEs in general. This documentation plug-in is installed by default. The Eclipse help system also includes a dynamic help feature. This feature opens a new window in the workbench that displays documentation relating to a selected interface element. To activate dynamic help, navigate to > . The rightmost window in Figure 1.26, "Dynamic Help" displays help topics related to the view, which is the selected user interface element. |
| |