I bought a wrecked XJ that sat under a tree with no gas cap for +2 years. It started right up and drove onto the trailer.
Test the CPS. and fuel pressure.
For 1996+ Jeeps, the OBD-II engine computer (ECU/PCM) re-boots, and the idle settings are deleted, when you: (1) let the battery run down by leaving the lights or radio on, (2) disconnect the battery for an extended period of time, (3) when the battery goes bad and needs replacing, (4) when the alternator is not properly charging the battery, (5) or when poor battery connections result in a voltage drop at the PCM or poor battery charging. Loose, corroded, or damaged battery cables or ground wires may also cause or contribute to the problem. A faulty Coolant Temperature Sensor may also cause similar symptoms. Testing of the CTS is recommended as part of the diagnostics. A poor ground at the ignition coil can also cause similar symptoms.
The reboot symptoms are: (1) having difficulties starting the engine without depressing the gas pedal, and (2) the engine will have a low idle and probably stall unless you keep your foot on the gas pedal. (3) The ECU will usually relearn the idle settings after a short period of driving and the engine may sometimes start and idle normally.
Suspect a low voltage issue from:
• dirty, corroded, damaged, or loose battery terminal or wire connections
• confirm all of the grounds under the hood are clean and tight
• internally corroded battery wires
• a short circuit or parasitic drain
• a failing battery
• a failing alternator
Perform routine maintenance of the start and charge systems. Remove, clean, and firmly reconnect all the wires and cables to the battery, starter, and alternator. Look for corroded or damaged cables or connectors and replace as needed. Copper wires should be copper color, not black or green. Battery terminals and battery wire connectors should bright silver, not dull gray/black and corroded. Do the same for the grounding wires from the starter to engine block, the ground wires at the coil, and the ground wires from the battery and engine to the Jeep's frame/body. You must remove, wire brush, and clean until shiny the cable/wire ends and whatever they bolt onto.
Jeeps do not tolerate low voltage, bad wire connections, or poor grounds.