Easiest way to connect to a junction box when the wires won't reach?
If you can already see that there is enough slack in the wires feeding the junction box, then go ahead and move it. DO NOT just pull the wires to test for excess slack. You run the risk of dragging the wires over something sharp, or pulling the other end out of whatever it's connected to.

Depending on the design of the fan, it might be easy to remove the existing cord and connect a new, longer one.

Otherwise just install a new junction box where convenient, and connect it to the old junction box, as you suggested.