For food preservation, such as pesto or jam, in jars, you'll need to sterilize the jar first.
It's simple and does not take all that long, but be sure to do this while you are making whatever you are meaning to preserve.
Start by putting the jar/s in a large pan and cover with water. Bring to the boil and boil for 10 minutes. Turn the heat off, but leave the jars in the water until you need them. Remove the jars from the hot water with tongs or something similar. Fill the jar within ½ inch from the top. Wipe off any spills with a clean towel. If you are making something that is oil-based, cover the top with oil and put the lid on. If you are making jam, you need to buy waxed paper discs and follow the instructions on the pack. Allow the jar to cool in room temperature for 24 hours before storing in cupboard or fridge.