I assume that your CJ doors are similar to my YJ doors.
The first thing to do is remove the striker bolt. That's the gizmo that your door latch grabs onto. Probably mounted on a plate just to the rear of the door opening on the pillar. I expect you need the proper sized torx bit to remove it. Do one side at a time to avoid brain damage.
With the striker bolt out of the way push the door shut. Does it fit the door opening?
If it fits, replace the striker bolt. There is probably a 1/4" to 3/8" adjustment up & down and in & out.
Your latch has two "catch" positions (half catch and fully closed). It sounds like your latch was catching on the first catch (half catch). The cure for that is to actually move the striker bolt out from the original position. It takes a bit of fiddling around to get the striker bolt just right. It helps to tighten the striker bolt tight enough to stay in place but not so tight that it can't be adjusted with a light tap from a hammer. Tap the bolt at the base, rather than on the tip. You will notice the door catching on the first catch and then as the door pushes the rubber gasket onto the tub, the second part of the latch should grab and hold the door securely shut.
If your door doesn't fit the door opening on the tub, you will need to loosen and adjust the hinges. Loosening the hinge torx bolts presents a whole new set of problems. The factory puts thread locker on the bolts and they need to be heated to break the thread locker bond. You want to loosen the door side hinges, not the cowl side hinge half.
Enough heat to break the thread locker bond will probable scorch your paint.
A proper sized torx bit is ABSOLUTLY essential for this operation. A too small bit will round out the teeth in the bolt head and then you will need to drill it out.
I use a 3/8" impact wrench with a torx bit to loosen and tighten the door hinge bolts. . A hand ratchet wobbles too much and eats up the teeth in the bolt head.
Once your doors fit the door opening, go ahead and replace the striker bolt and adjust it as stated above.
The above works for YJ and probably CJ. If you have other fit problems, post a few pics.
Good Luck, L.M.
1987 YJ-4.2L-Standard Shift- Re-manufactured Carter Carb-2" body Lift-31X10.5X15 BFG KOs-188K Miles
HEI distributor with computer and all related relays and wiring removed.
No back seat.
12K Badlands winch with dual batteries.