I just put a 97 4.0 (after I rebuilt it) into my 95ZJ 4.0. It was a direct swap with the exception of the idle pully next to the a/c compressor (they were about 1/4" different in size, although I think I could have used either one) and the temp sensor on the thermastat housing.
The valve covers were different cast aluminum vs stamped steel (no drama there).
The 93-97 4.0 blocks (maybe others) are almost identical as far as bolt on points. The accessories change, on some, but if you stay close in years, it should be pretty straight forward.
Just remember.... if you change motor years, make sure when you need parts that you choose the right year for the part. (ie, 95 valve cover gasket is different that a 97 valve gasket... as is a temp sensor on a 95 vs 97.
2008 Jeep Wrangler X (Hard Top)
Incubus Off Road 511's with BFG 285/70-17
1998 Jeep Cherokee Sport
4.0L/AW4, Yakima Roof Rack