4

Trying to debug a NPE from a remote machine on eclipse, I cannot recreate the test case so wish to set the variable equal to null during runtime within the debug variables however. I am only given two options to set it, to a string (it's type) and via expression. I have tried via expression entering null and = null. However it does not allow me to do it.

edit: I enter

null 

=null

However I get the error message evaluations must contain either an expression or a block of well-formed statements

4
  • can you paste exact expression in here ? Commented Jun 25, 2014 at 17:54
  • 1
    Have you tried (String) null ? Commented Jun 25, 2014 at 18:01
  • @vikingsteve tried it and got the same error as the edit :( Commented Jun 25, 2014 at 18:02
  • Perhaps, use IntelliJ? Miles better than Eclipse... Commented Jun 25, 2014 at 18:19

2 Answers 2

9

You can use Display View for that. Windows -> Show View -> Display

Enter your expression in the Display Tab and execute it. You can see the execute buttons on top right corner with letter J on them. Simple execute yourVar = null;. It should set yourVar to null.

Sign up to request clarification or add additional context in comments.

4 Comments

Does you class include generics?
no it does not. I don't understand why this is being made so difficult. How else does anyone remote debug a NPE if they do not have the test case.
It googled it and it looks like an eclipse bug. Consider upgrading your eclipse.
Just want to add, to execute the command you need to do a right-click to show the option of the context menu where you can execute it. Pressing ENTER wont do it like the [Intermediate] window of Visual Studio
0

Click in...

Window - Show View - Expressions

...and enter null for variable.

enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.