Take NJ Transit to New York Penn Station. Transfer to Long Island Rail Road (LIRR) to Jamaica (any line except Port Washington Branch) and take the Airtrain upstairs. On a good day, probably 3-4 hrs
Hamilton train station to Penn Station NYC via NJT train is $16. From there it's probably easiest to Uber to JFK.
Thanks! Your answer is awaiting moderation.