Will you be at EclipseCon?

Launching

What is contextual launching?

Contextual launching is a new, simpler way of launching in Eclipse built using all of the familiar launching metaphors.

In the traditional launching mode, Eclipse would simply launch the last thing that was was launched. With context launching, what gets launched is determined by what the current selection in the workbench is. For example, if you have a Java file with a main method open in the editor, pressing "run" (or debug) will launch it as a Java application. Even if you have not created or know how to create a launch configuration for the launch, the context launching framework will create one for you (which you can edit at any time via the launch configuration dialog).

Context launching is the default method for launching in 3.3 M7 builds and later.

How do I turn off contextual launching?

If you just can't get over the old way of doing things, you can do so on the Run/Debug > Launching Preference Page. Change the Launch Operation option to "Always launch the previously launched application".

I can run a program but not debug it???

This problem happens quite often where a user can run a program, but as soon as they try to debug it they get errors about 'unable to connect' or even more nasty looking ones like:

99% of the time, the problem is just a simple misconfiguration of either the users' computer or the configuration to be launched.

Here are some of the solutions to the 'run but not debug' problem

Check if you computer has a firewall. If it does make sure that eclipse has TCP access to 'localhost', as the debugger uses TCP to communicate with the target VM. Note: there are no port ranges, as the platform Eclipse debugger scans for the first available port to use, there is no set range it will choose from.

If you are using Linux, check that your hosts file, located in /etc/hosts, has a correct mapping for 'localhost'. If there is no mapping for 'localhost' than the debugger cannot resolve connecting to the local VM via TCP. Following is an example of a hosts file with a correct mapping.

# Do not remove the following line, or various programs
# that require network functionality will fail.
::1 localhost.localdomain localhost
127.0.0.1 localhost

If you edit the launching environment (via the 'Environment' tab in the launch dialog) and have selected to 'replace my environment', you must ensure that the variables you specify as replacements are sufficient for launching. More specifically, you have to include all of the environment variables that your system and Eclipse needs to launch. The safest course of action when you want select the 'replace my environment' is to add all of the variables and your own, and to only remove those which you know for a fact are not required by your system or Eclipse.

It could be that there is some garbage text in your environment. To find out try typing either

cmd.exe /C set (in Windows)

or

env (in Linux or Mac)

. The output produced should look like the following, where there are variables followed by an '=', followed by the value of the variable.

If there is garbage text in this output you need to clean up your system variables, otherwise the debugger cannot parse your environment. The other solution to this is to migrate to using Eclipse 3.3.1 or newer, where we added support for ignoring garbage text in your environment.

If you have the JRE you wish to use for launching installed in a jdk path, the debugger will not start complaining about its inability to find system libraries.
For example, lets say you have Java 6 installed in C:\java\jdk6. Now lets say that in Eclipse you have your default JRE (the one you want to use for launching) set to the installed path C:\java\jdk6. Pre-3.3.1 debugging will not work because we would scan the current directory to find the system libraries needed to debug, and find none. The problem was that we were not correctly appending paths in our debugger to find the system libraries in the JRE folder of the install location. This has been fixed in Eclipse 3.3.1.

Java Debugging

Why are my step into, step out, step return buttons disabled?

Check that you are suspended (manually or on a breakpoint) and have a valid stack frame selected in the Debug view. Sometimes the stack frame selection is lost. If this is happening to you often and you have a test case to reproduce the problem, please file a bug.

What is hyper-link debugging?

Hyperlink debugging is the coolest and fastest way to debug through Java code. When suspended, holding Ctrl + Alt and clicking on a method will result in the debugger attempting to resume to that line and step into the method you clicked on.

What cool features do I get if I use a Java 6.0 VM?

There are 3 significant debugging features that you can take advantage of when using a Java 6.0 or later VM (note that not all VMs may support all of these features).

All Instances - Queries the VM for all instantiated objects of a specific type and lists them in a popup dialog (which can be persisted to the Expressions view). This feature can be accessed from the run menu and several context menus. You must have a java variable selected in the variables or expressions views, or a java type or constructor of a type selected in the Java editor.

All References - Queries the VM for all objects that hold references to a specific object and displays them in a popup dialog (which can be persisted to the Expressions view). This feature can be accessed from the run menu and certain context menus when you have a java variable selected in the variables or expressions views.

Force Return - Allows you to immediately return from the method the debugger is suspended in, returning a value of your choice. This feature is available from the run menu and certain context menus. To return a value, you must select a variable or text that can be evaluated. The result of the evaluation will be passed to the caller as a return value. If the returned value is of an incompatible type an error dialog is shown. When inside a method that returns void, the selection will be not be evaluated.

Variables View

What are logical structures?

Logical structures are alternative ways of displaying the contents of items in the variables, expressions and registers views. The option to show logical structures is controlled by a button in the view toolbar with the tooltip "Show Logical Structures". By creating and using logical structures you can display the contents of an item in a logical and practical manner instead of displaying information determined by the implementation. JDT provides several logical structures for java types. Collections types are displayed as an array of values, Maps are displayed as an array of map entries (and map entries have a logical structure to be displayed as key/value pairs). Finally, Composites are displayed as an array of children Controls. JDT also provides a preference page (Java > Debug > Logical Structures) where you can create and edit logical structures of your own.

What are detail formatters?

Detail formatters are alternative ways of determining the text that is displayed in the detail pane of the variables and expressions view when a Java variable is selected. By default, when a java type is selected, the detail pane will display the toString() result in the detail pane. A detail formatter will provide a snippet of code that will return a String to display in the detail pane. You can add and edit detail formatters on the detail formatter preference page (Java > Debug > Detail Formatters).

What is the detail pane?

The detail pane is the separate area of the variables, expressions and registers views that displays more detailed information about the currently selected item in a text format. By default selecting a Java variable will result in the toString() result being displayed in the detail pane. The detail pane can be resized and its location can be changed by using the Layout submenu in the view drop down menu. By using the org.eclipse.debug.ui.detailPaneFactories extension point, plug-ins can contribute custom detail panes that can display information using different widgets.

How do I fix an IllegalArgumentException coming from the Variable View's SashForm?

This was fixed in 3.3. An invalid value is stored in the view's memento. You can clear out this value by clearing your workspace preferences, or opening <workspace
loc>\.metadata\.plugins\org.eclipse.core.runtime\.settings\org.eclipse.debug.ui.prefs and changing SASH_DETAILS_PART to a value of 6 and SASH_VIEW_PART to a value of 13. See Bug 199385 for more information.

Console

Why does Eclipse sometimes hang when a lot of output is written to the console?

If you are writing a large amount of data to the Console streams from the UI thread, the console will be unable to clear the buffer. See Bug 136943