Its never quite that easy Im afraid.
There are two 4.0 motors out there for those model years. There's the 4.0 OHV (VIN X), and the 4.0 SOHC.
I would guess you have the 4.0 SOHC, as the OHV doesn't blow up. You better check what you have for sure.
Also, there are differences such as EGR valve, or not....that kind of stuff that might need to be swapped from your old motor to the new one IF the new motor from the wreaker doesn't have it.
If you have the 4.0 SOHC motor and want to pick one up from the wreaker, you might want to research the 'death rattle' thats talked about here all the time. Any SOHC motor from the wreaker should have its timing chain tensioners re-done before installing the motor (The motor has to be removed to do the rear chains anyway).