Peel, core and roughly chop the pineapple. From 1 whole pineapple I got around 850g of pineapple flesh. Place into a food processor (in 2 batches if necessary) until more finely chopped.
Place the pineapple, coconut, juice of half a lime, sugar, water and spices into a large saucepan and bring to the boil. Keep track of how many spices you used as you will need to remove them later after the jam has cooked. Reduce the heat and cook, simmering uncovered for about 30-40 minutes until the pineapple has softened.
Add half the rum and lime zest and cook, stirring occasionally until thickened and most of the liquid has evaporated (around 50 minutes). Remove the cardamom pods, cinnamon sticks and star anise. Stir in the remaining rum and lime juice. Pour hot jam into hot sterilised jars, seal immediately and turn upside down to cool. Store in a cool, dark place or refrigerate after opening.