Depends....
If you're pre-1991, your XJ doesn't store or throw codes.
If you're 1991-1995, you're OBD-I, and the systems stores and throws codes. Retrieve by turning the key ON-OFF-ON-OFF-ON within 5 seconds, and watching the "Check Engine" light. Find a reference for "diagnostic trouble codes" for explanation.
If you're 1996-up, then your system is OBD-II, and you'll want a "code reader" to retrieve and clear codes. Expect this to run anywhere between $150 and $2000 (there are hobbyist units, which run on the low end) to purchase.
5-90