To the OP, if you dont have that much luggage, I mean very little, take the AirTrain transfer to the A train and head to Penn Station in Midtown. From there get a NJ path train to EWR, runs directly to the airport. Thats how I have done it...but if you have luggage...then just take a taxi into NJ. And 5 hours is cutting it kind of close...so its probaly best you take a taxi.
going from JFK to EWR