Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
CarlosRoggan
Product and Topic Expert
Product and Topic Expert
0 Kudos
3,112

Within this document, I’ve collected some tips that I consider useful.

This document is addressing users that are new to Eclipse and I hope that it helps to enjoy the work with Eclipse…;-)

The reason why this document is located in the SAP NetWeaver Gateway Space is that many users who want to try NetWeaver Gateway Productivity Accelerator (GWPA) have never used Eclipse before and may consider this document as helpful.

This document is related to the Prerequisites document for the GWPA tutorials, and specially to the Eclipse Preparation document

Please note that the order has no relevance with respect to the importance of the tip.

Those of you who are missing a specific tip, or have something in mind, please send me a mail so that I can include it, or add your tip directly to the comment section.

Tip: multiple Eclipse installations

You can have multiple Eclipse installations on your machine.

Since everything that Eclipse needs is extracted in a folder on your file system, you may have multiple Eclipse installations in several locations on your file system.

You could e.g. have 1. one NWDS, 2. one Kepler version of Eclipse for standard Java-development and 3. one Juno version of Eclipse for GWPA (Gateway Productivity Accelerator).

Each of your Eclipse installations should have its own workspace.

As per default, Eclipse asks for the location on start up (can be configured. See tip below)

Personally, I have multiple Eclipse installations on my file system, and I create a workspace-folder inside each installation folder, and I pass the location to Eclipse in a command line option.

Note: such options for start up of Eclipse can be specified in the properties of a shortcut, but also in the eclipse.ini file. (See the respective tip below)

Tip: Eclipse options

There are quite some start up options that can be passed to Eclipse.

One way is to pass such a start up option in the command line.

Alternatively, the Eclipse.ini file can be edited (see respective tip below).

In order to add a command line option, proceed as follows:

In your “eclipse”-folder, you’ll find the “eclipse.exe” file.

Select it with a right mouse-click, drag it to your Windows desktop, release the mouse and choose “Create shortcut here”.

Give the shortcut a meaningful name, e.g. “GWPA”.

Then open the context menu on it and choose “Properties”.

In the “Target”-field, append a space, then add the desired option.

Example 1: The workspace

If you specify the workspace in a start up option, you don’t need to click on the workspace popup on every Eclipse start up.


-data “C:\<path>\<workspaceName>”









My shortcut looks like this:

Example 2: the Java VM

If you have several Java-versions on your machine, it makes sense to specify in a command line option which Java should be used for running this Eclipse.

e.g.


-vm C:\java\sapjvm7.1\bin\javaw.exe









After starting Eclipse, you can verify the used java-version in the preferences:

Note: if you specify the java.exe instead of the javaw.exe, you’ll get a command shell on start up. This is useful in conjunction with the options -consoleLog and -debug, when you want to see the system.out while working with Eclipse.

Example 3: Console Log

It can be helpful to start Eclipse and have a console window where all system.out logs and traces are printed to.

If you start Eclipse with java.exe instead of javaw.exe, then you have the command shell in the background.

And if you furthermore specify the option -consoleLog as parameter, then you’ll get all logs, e.g. all System.outs, printed to the console

The option to be set is:


-consoleLog










Example:


-vm C:\java\sapjvm7.1\bin\javaw.exe -consoleLog









Example 4: language

If you want to try your translated resource bundles, you can specify the language with the following option


-nl <language>









Example:


-nl en









Example 5: Heap dump

This is a pure Java VM setting. It tells Java to write a heapdump, if an OutOfMemoryError occurs.

This setting doesn’t have any performance drawback, since it is activated only after the process has already gotten unusable (due to the OutOfMemory)

If such an error occurs, the dump file is created in the installation folder.

The option is:


-XX:+HeapDumpOnOutOfMemoryError









Tip: The eclipse.ini

You can find this file in the installation folder.

It is a text file which can be edited by Eclipse users.

Basically, it is just a collection of command line options, which are used on Eclipse start up.

As described in the respective tip, there are quite some start up options that can be passed to Eclipse.

One way is to pass such a start up option in the command line (see respective tip). Alternatively, the eclipse.ini file can be edited.

Editing the eclipse.ini is the preferable way if you’re adding more than one option, because you get a better overview.

You’ll see that you always have to start a new line for each option and for the value of the option.

If you get an error after editing the eclipse.ini, this is most probably, because you’ve added the option at the end, after –vmargs. As a consequence, the option is considered a VM-argument and the VM cannot understand the argument and fails.

Here’s an example of how such an eclipse.ini file could look like:


-vm


C:\java\sapjvm7.1\bin\java.exe


-data


C:\IDE\GWPA\gwpaWorkspace


-consoleLog


-debug


-startup


plugins/org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar


--launcher.library


plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.200.v20120913-144807


-product


org.eclipse.epp.package.jee.product


--launcher.defaultAction


openFile


--launcher.XXMaxPermSize


256M


-showsplash


org.eclipse.platform


--launcher.XXMaxPermSize


256m


--launcher.defaultAction


openFile


-vmargs


-Dosgi.requiredJavaVersion=1.5


-Dhelp.lucene.tokenizer=standard


-Xms40m


-Xmx512m


-XX:+HeapDumpOnOutOfMemoryError










Tip: configure workspace

You should have a look at the possible settings in the Eclipse preferences.

Go to

Main menu -> Window -> Preferences

In the left pane, unfold the “General” and the “Workspace” node

Also, check the node:

General -> Startup and Shutdown -> Workspaces

Here you can deselect the check box “Prompt for workspace on start up”, if you always use the same workspace:

Tip: Check for updates

As you know, Eclipse is a platform and all functionality that you use is contained in plug-ins which are stored in update sites and can be fetched and installed from there.

Usually, the providers of plug-ins (e.g. SAP, which provides GWPA - SAP NetWeaver Gateway Productivity Accelerator) also provide newer versions of plug-ins after some time.

Plug-ins (i.e. bundles) are identified by their unique name (i.e. BundleSymbolicName) and the version (e.g. 0.1.22).

So if there’s a newer version of the same bundle available on the update site, you can easily install it to your current Eclipse installation.

You can let Eclipse automatically do that.

Main menu -> Help -> Check for updates

Please refer as well to the document Getting started with GWPA - Eclipse Preparation

Tip: Network Settings

If you’re working on a machine that is located inside a company network, you need to go through a proxy, when accessing a URL in the internet.

You can verify the usage of a proxy in your browser settings (e.g. Internet Explorer).

In such case, Eclipse needs to be configured to use the same proxy.

This is done as follows:

Go to

Eclipse main menu -> Window -> Preferences -> General -> Network Connections

From drop-down “Active Provider” select “Manual”.

Additionally, it might be necessary to tell Eclipse to not use the proxy for URLs which are located inside your company network and for URLs which point to your own machine.

The following screenshot displays the settings which work for me (the real settings are similar):

In order to verify if the proxy settings are working fine for Eclipse, you can do the following:

You can use the browser that is provided inside Eclipse and open any website located in the internet.

Open the browser, which is an Eclipse view, as follows:

Window -> Show View -> other -> “Internal Web Browser”

If you face errors, try restarting Eclipse in order to make sure that the proxy settings are really used by Eclipse.

Tip: The Error Log view

Eclipse is an open framework. The more plug-ins you add, the more issues might occur due to interferences of plugins with each other.

If you get unexpected results or find the behavior strange or if you get a popup telling you to “check the error log for details” – in any case, you should always have the Error Log view open somewhere in your perspective.

In order to open it, go to

Main menu -> Window -> Show View -> Other -> General -> Error Log

The view allows to filter (e.g. hide info messages), export the log file, clear the log, etc

Tip: The Plug-ins views

If you have trouble because you don’t find the functionality you were looking for, e.g. after installing additional plug-ins, you can proceed as follows for further investigation:

Open one of the 2 plug-ins views.

Window -> Show View -> Other -> Plug-in Development -> Plug-in Registry

Search for the plugin (or the namespace) that should provide the expected functionality

Example: Type “*android*” in the filter field, then press the button “Collapse All”.

Check if the plug-in is available and if yes, check if its status

If the icon contains a green arrow, then the plug-in is started and running

If not, then the plugin is available and OK, but has not been started (due to lazy loading)

If the icon contains a red error decorator, then there’s anything wrong with it.

In such case, you can try the “Diagnose” action.

First, you have to enable it: Select the plug-in, open the context menu and click “Show Advanced Operations”

Then open the context menu again and click on “Diagnose”. You might get a useful result.

For more information about the status of plug-ins, please refer to my OSGi document.


There’s a second view that as well offers an overview over the installed plug-ins:

Window -> Show View -> Other -> Plug-in Development -> Plug-ins

Tip: The Javadoc view

1. Variant

Simply open the Javadoc view via the Eclipse menu

Window -> Show View -> Other -> Java -> Javadoc

2. Variant

In the Java Editor, move the mouse over a type or a method (etc), wait for the tooltip, move the mouse into the tooltip, wait until the tooltip window expands, then click on the @ symbol at the bottom of the tooltip to see the Javadoc in the Javadov view.

See screenshot:

Tip: Filter settings

The tool that is commonly used in Eclipse to view and browse Eclipse-projects and folders is the Project Explorer view.

It can be configured to hide files or objects which are typically never used.

The filter settings dialog is invoked via the drop down list of the Project Explorer view:

Then click “Customize View”.

A dialog is displayed which shows a list of all existing filters.

Examples for filters:

  • One example of a typically used filter is to hide "closed projects".
  • If the entry “.* resources” is selected, you don’t see resource files. For example, this filter hides the .classpath and the .project files, which are sometimes interesting to view.

Tip: Eclipse metadata folder

Eclipse keeps track of all settings and its own metadata in the .metadata folder, which is located in the workspace folder.

  • The .log file
    The most prominent content of the .metadata folder is the .log file.
    It is the Eclipse log file, where errors and warnings and other logging messages are written to.
    During your work with Eclipse, you'll typically use the Eclipse Error Log view. But if you have to send the file to anybody, or if you want to check the log while Eclipse isn’t running… here it is.
  • The .lock file
    It might occur that your Eclipse crashes and that afterwards Eclipse refuses to start saying that the workspace is already in use.
    Eclipse keeps track of the usage of a workspace by creating the .lock file (and deleting it after shutdown of Eclipse).
    So if you have the issue that Eclipse refuses to start saying that the workspace is already in use,  just delete the .lock file manually.
  • The .plugins folder
    Here, the settings are stored per plugin.
    Every plugin that contributes to Eclipse can store its settings via Eclipse-means.
    For example, the preferences are stored here:
    <workspace>\.metadata\.plugins\org.eclipse.core.runtime\.settings
    Another example would be the existing launch configurations, which are stored in
    <workspace>\.metadata\.plugins\org.eclipse.debug.core\.launches

Tip: Add plug-ins to Java search

You know this situation:

In your Java code, you want to use the API of a plug-in that is provided in Eclipse.

You want to open the respective class.

You press Ctrl + T, and in the dialog “Open Type”, you enter the name or the namespace of the desired class.

But the desired class is not displayed.

The reason is that the class, resp. the containing plug-in, is not in the workspace.

So now you have to import the plug-in into your workspace.

But there’s an easier way:

Open the Plug-ins view

Window -> Show View -> Other -> Plug-in Development -> Plug-ins

Press the button “All All Plug-ins to Java Search” on the toolbar of the view.

That’s it.

After that, all classes will be displayed when pressing Ctrl + T

You don’t have to import any project into your workspace.

Personally, I was extremely satisfied when I discovered this great, but well hidden, functionality!  😉

You can also use this view to import selected plug-ins into your workspace

Tip: Uninstall features

If you’ve installed additional software and want to get rid of it – you need to find the “uninstall” functionality, which is a bit hidden in the Eclipse main menu.

Go to

menu -> Help -> About Eclipse

In the dialog, press "Installation Details".

In the dialog, open the tab "Installed Software" and select the software to uninstall.

Press the "uninstall" button.

Tip: Shortcuts in Eclipse and in the Java Editor

You really have to know the following keyboard shortcuts when working with Eclipse.

Please note that there are many, many more.

Ctrl + SSave (+ Build)
F3Open Declaration (put cursor on a Type, then press F3, in order to open that type)
F4Type Hierarchy (put cursor on a Type, then press F4, in order to display all super classes)
Ctrl + TQuick Type Hierarchy
Ctrl + DDelete line
Ctrl + OWhen Editor has focus: opens a dialog which shows all members of the active java class. (press Ctrl + O again to show inherited members)
Ctrl + Shift + OOrganize Imports
Ctrl + Shift + FFormat
Ctrl + Shift + TOpen  Type (here you can enter the name of a class in camel case, in order to open it)
Ctrl + Shift + GReferences in Workspace (put cursor on a type, then search where this type is used)
Ctrl + Shift + Lopens a window displaying keyboard shortcuts
Ctrl + 1Quick Fix (e.g. add imports, create method, surround with try). Put cursor on erroneous code and press Ctrl + 1
Ctrl + 1Quick rename. Put cursor on variable or method name (anywhere in code), press Ctrl + 1, enter new name and press enter.
Ctrl + F6Switch between open editors
Ctrl + F7Switch between available Views
Ctrl + 7comment or uncomment current line
Ctrl + 3Open the Quick Access, which allows to search and quickly open views etc. Very useful.
Ctrl + .Ctrl + dot : jumps directly from one (compile-)error to the next one (direction down)
Ctrl + ,Ctrl + comma : the same, but direction up
Ctrl + SPACECode completion
alt + arrowUpplace the cursor in a line in the java editor, or do multiselection of lines. Then press Alt and up- or down-arrow, in order to move the selected line(s)
TAB

The usual TAB behavior, but works fine with multi selection.

Select multiple lines in the java editor, place the cursor in front of them, then press tab or shift tab, in order to move the selection to the right or left

Ctrl + MPress Ctrl + M in order to maximize the java editor (press again in order to go back to previous size)
Ctrl + F11Run the last launch
Ctrl + F10Run the last launch in debug mode