Your jam will have a grainy texture if the sugar has not dissolved in the jam, or if you scraped down the pot sides when pouring the hot jam into your hot jars.
To stop this from happening with your next batch, whisk the sugar in very well when adding to the hot fruit mixture, heating on medium for a few minutes while the sugar dissolves. Then bring back to a boil and continue with the next step in the jam recipe. You can scrape down the sides while you boil the jam, but make sure it has all dissolved before turning the heat off - and don't scrape the sides of the pot once the heat has been turned off.