-6
\$\begingroup\$

When I execute this code it gives me the Exception Glthread 8 Java.lang.null.pointer

MouseJointDef md = new MouseJointDef();  
md.bodyA = _body;
md.bodyB = _body;
md.target.set(locationWorld);
md.collideConnected = true;
md.maxForce = 1000.0f * _body.getMass();

_mouseJoint =  (MouseJoint) _world.createJoint(md);
_body.setAwake(true);

Thanks.

\$\endgroup\$
7
  • \$\begingroup\$ Which line exactly? \$\endgroup\$ Commented Aug 13, 2011 at 10:47
  • \$\begingroup\$ Body A and B are the same for the joint? You sure that makes sense? \$\endgroup\$ Commented Aug 13, 2011 at 10:48
  • 4
    \$\begingroup\$ Voted to close as too localized. Make use of the debugger? \$\endgroup\$
    – bummzack
    Commented Aug 13, 2011 at 11:10
  • 1
    \$\begingroup\$ Have you stepped through the code in a debugger to see which variable is null? \$\endgroup\$
    – ChrisF
    Commented Aug 13, 2011 at 13:31
  • 1
    \$\begingroup\$ GDSE is not a debugger \$\endgroup\$
    – Ray Dey
    Commented Aug 13, 2011 at 15:20

1 Answer 1

5
\$\begingroup\$

This is a case of "give a man a fish/teach a man to fish". You should learn to use the debugger to figure this problem out yourself.

Here is a good place to start:

http://www.infinitezest.com/articles/debugging-an-android-application.aspx

and you can find more here:

the google

FWIW as your code stands, the most likely perpetrator are md.target, _body and _world.

\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged .