How to Create Joints

I have three game objects. Cube, Cylinder and a Sphere.

Now the Sphere is movable in space using keyboard inputs. What i need to do is i need to create the Cube stationary and “join” the cylinder to cube. the cylinder is much like a beam. so the beam starts from cube. the sphere needs to be positioned somewhere in the cylinder body.

What i need is now, when i move the sphere i need to move the beam with spear. But the other end of the beam needs to be fixed to the cube. So beam will not have any translations but it will rotate from a corner.

You can add hinge joints(rotable ones), by going to menu, add component, physics, hinge joint

its not working for me. The whole thing goes together as they are welded.