Many insects don't have a nervous system. Also, some plants respond to physical damage (albeit very differently than an animal) and they don't have nervous systems, either.
It would also be possible to build a machine that can detect damage to itself and program it for self preservation, but that doesn't intrinsically mean it would feel pain.