Ted
Ted

Reputation: 20184

Debugging in Eclipse (Java); can't hover over a variable when breaking to view the value

I'm using Eclipse to code Java (for Android) and I'm trying to debug the code as I normally do (i normally do C# though).

From what I can tell, debugging in Eclipse is really bad. I don't know if I'm doing something wrong, but it seems to be just awful.

This is the code that is being run, I get some sort of exception and I want to see what the Exception is, by breaking in the "catch"-clause and viewing the variable "e":

try
{
    ConnectivityManager connectivityManager = (ConnectivityManager) this.getSystemService( Context.CONNECTIVITY_SERVICE );
    NetworkInfo activeNetInfo = connectivityManager.getActiveNetworkInfo();
    NetworkInfo mobNetInfo = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
    NetworkInfo.State state = mobNetInfo.getState();
}
catch(Exception e)
{
    Log.v("MyAp", e.toString()); // I break on this line, and want to see what e is
}

The problem is that I cannot see "e" by holding my mouse over it (as I can in my beloved Visual Studio).

Now, I know that I can bring up the tab "Variables" which lists all variables accessible from when I'm breaking, but that's not optimal.

Just so I know - Eclipse has no way of "hovering" over the variable you are interested in, as in Visual Studio?

Edit

Thanks for the answers. However, still have the same problem =(

Upvotes: 6

Views: 13181

Answers (9)

I think that the correct answer is the @RogerThomas one.

Go to 'Window' -> 'Preferences' -> 'Java' -> 'Editor' -> 'Hovers' Then check 'Variable Values'.

If the 'Variable Values' option collides with 'Combined Hover', uncheck last one or configure new keys for it.

Upvotes: 0

Nisarg Panchal
Nisarg Panchal

Reputation: 131

Found it, Goto: Preferences > Java > Editor > Hovers - Javadoc (click on it and remove the ctrl+shift keys from there), then it should work normally.

Upvotes: 0

jsalatas
jsalatas

Reputation: 255

Go to Preferences -> Java -> Editor -> Hovers, and click Restore Defaults.

Upvotes: 0

Bryan Shannon
Bryan Shannon

Reputation: 11

I have also found that in the "Debug" view (the tab with the little green bug as an icon) where it shows all the threads, Eclipse sometimes doesn't show the variable's values if the currently breakpointed thread isn't selected.

If anyone else runs across this problem, then you might have hit a breakpoint, but the currently running thread isn't the one highlighted in the "Debug" window.

Upvotes: 1

Stijn de Witt
Stijn de Witt

Reputation: 42184

There seem to be bugs in Eclipse related to this:

So, yes it is supposed to work, but it doesn't always. I'm having this issues on some classes. It seems to be consistent which classes work and which don't, probably related to what jar the class is coming from etc, but I have no real clue as to what causes it. Would love to see some reproduction scenario.

Upvotes: 4

Roger Thomas
Roger Thomas

Reputation: 91

Go to Preferences-> Java-> Editor-> Hovers and tick the box 'Variable Values'. If you want Hover to happen automatically then leave the Key Modifier section blank.

Upvotes: 9

Powerlord
Powerlord

Reputation: 88826

As far as I can tell, you have to be in Debug view in order to hover over objects and see their properties. At least that's how my copy of Eclipse 3.4 works.

Of course, you also need to be in Debug view to have the Step Into, Step Over, Continues, etc... buttons...

Upvotes: 0

kfb
kfb

Reputation: 6532

This might seem a bit strange, but do you know that the code window has focus? I have observed that sometimes the appearance of the tooltip depends on whether a view has focus or not (which I guess is an SWT bug).

Upvotes: 1

Jeremy Raymond
Jeremy Raymond

Reputation: 6027

You can also highlight the variable, right click, and choose to watch it. Then it shows up on the watch tab. You can also set automatic break points that trigger on the exception being thrown rather than at a particular line of code. There is not 'hover' option to view the variable as in Visual Studio in recent versions of Eclipse.

Upvotes: 1

Related Questions