you should be at airport 2hrs before flight. You need to check in minum 45min - 1hr before flight leaves.
You need to maybe look for a night train (stay in onsite hotel) or take a taxi.
Don't know how far you are from JFK.
You could try for a later flight but this will also cost you.
I wish you all the luck, sorry i dont have more specific information