The LIRR is a railroad system that has trains that go on train tracks above ground and sometimes underground as it hits Manhatten and brooklyn. The NYC subway is totally different. The NYC subway has buses that run on streets underground and sometimes elevated. The NYC is essentially an urban bus system that has buses that go more underground.
Take the Long Island Railroad to Jamaica and change for a train going to Valley Stream. If you are not near the LIRR, take the E or J subway train to the Jamaica LIRR station and change to the railroad there. The only train that stops in Jamaica is the LIRR. The subway does not go into Nassau County.
From JFK, take the "Air Train" to Jamaica Station. There, you can catch the LIRR (Long Island Railroad) into Penn Station in Manhattan. From Penn Station, you can catch an Amtrak train upstate to Albany.
The LIRR (Long Island Railroad) stops at Freeport. It would be a shorter trip if you could board the train at the Hunterspoint Station in Queens, but I guess the LIRR does not run from Hunterspoint to Freeport, because when I entered it into the schedule finder, it said that, "This station combination is invalid." So I guess you have to start out from Penn Station. For subway directions to Penn Station, please ask another question, i.e., "How do you get from [insert address here] in Brooklyn to Penn Station?" See the Related Link below for schedules and fares for the LIRR.
You can take the Babylon branch of the Long Island Rail Road (LIRR)from Penn Station (at 34th and 7th) to the Freeport Station and take a bus to Jones Beach. You can also take the LIRR to the Hamptons.
Amagansett - LIRR station - was created in 1895.
Hewlett - LIRR station - was created in 1869.
Oakdale - LIRR station - was created in 1868.
Pineaire - LIRR station - ended in 1986.
Pineaire - LIRR station - was created in 1915.
Grumman - LIRR station - was created in 1942.
Bayport - LIRR station - ended in 1980.
Bayport - LIRR station - was created in 1869.