There are a few different ways to enchant swords in Minecraft. One way is to use an enchantment table. Another way is to use an anvil.