You don’t get to reuse anything. You would need the 4.0 tranny and Tcase as well, as they are all different. The frame mounts are different, wiring harness fan shroud, starter, everything. It is basically an entire drive train swap and you could just as easily drop a 5.3 LS/TH350 into it and be much happier for about the same amount of work an money.
However, if you insist, it can and has been done. But you pretty much need a whole donor vehicle next to it. I sure wouldnt waste time putting an older 4.2 into it. You would want to stick with at least a 94+ HO 4.0 engine. A good option would be to pick up a wrecked XJ that had a good drive train and swap the engine, tranny and TCase right into and just thin the harness down to the bare minimum in the process.
Again, just as much work as a 5.3 swap.
I had a 2.5 TJ and quickly learned a 4.0 swap was not as simple as I thought.