You can find complete information on the LIRR and subway at http://mta.info.
Generally, the LIRR is faster, more comfortable, and more expensive.
The LIRR takes 20 minutes from Jamaica to Penn Station. It is a commuter train with regular coach cars; there is a seat for every passenger and overhead racks for small bags. The regular adult fare is $9.50 during peak times (M-F from about 6-10 AM in this direction), $7.00 at other times on weekdays; It's $4.00 on Saturday and Sunday. The trains run at fixed times and you can find a timetable here.
The E train takes about 40-45 minutes to Penn Station. (Note that Airtrain access is via the Sutphin Blvd stop, not Jamaica Center.) Cars have limited seating and no luggage racks; there is a fair chance that you will have to stand with your luggage for the whole trip. The regular adult fare is $2.50 at any time of day. The trains run frequently but don't have a fixed schedule.
You will need to buy 2-3 separate tickets for the different legs of this journey:
To ride Airtrain from JFK to the LIRR or E train, the fare is $5, paid with a Metrocard. You can get a Metrocard at a vending machine; there should be some on the Airtrain platforms or inside the airport. Cash and credit cards are accepted. There is a $1.00 surcharge for the Metrocard itself, or if you already have one, you can just add money to it. More information about Airtrain can be found here and here.
If you take the subway, the fare is also paid with a Metrocard.
If you take the LIRR, you should buy a ticket from a vending machine on the LIRR platform before boarding, which will accept cash or credit cards. If you don't, you can also buy a ticket from the conductor on the train, but there is a surcharge of about $6 and only cash is accepted.
When you get to Penn Station, you'll need to buy another ticket for NJ Transit, preferably from a vending machine (cash or credit). (There is also a staffed ticket window, and you can also buy from the conductor on the train, but again there is a surcharge.) The regular adult fare to Newark Airport is $12.50. You use the same ticket to ride the EWR Airtrain monorail from the Newark Airport station to the airport terminal itself, so do not lose it.
Note that the subway, LIRR and NJ Transit platforms are all in different parts of Penn Station, so allow yourself some extra time to navigate your connection there.
You might be able to squeeze in an hour or so to look around NYC. I would suggest that when you get to Penn Station, you check the schedule of departing trains (you want either the Northeast Corridor or North Jersey Coast lines), choose a train that will get you to EWR with as much time as you want (I'd allow 30-40 minutes from Penn Station to EWR's terminal), and then see how much time you have in between.