Well, there's a few different ways:
1) Random Luck: Person accidentally pulls out of javelin, uses semtex, gets killed, explodes. Javelin glitch is formed.
This takes for ever and is completely random. Chances are this won't happen to you, so time really doesn't matter.
2) Glitch Hunting: You go into a private match and mess around with different attachments, perks, and special guns. You end up randomly tapping some buttons, jumping off the top of rest, and exploding on impact with your Javelin. (Javelin glitch formed again!)
Takes between hours and days to find a glitch, depending on how long the game's been out (the longer the game's been out, the more found glitches/patches).
3) Idea Testing: You notice that the javelin takes longer to pull out the first time you do so in one life, so you figure that you might be able to exploit that by canceling the action by using a separate action, such as pulling out a grenade. You do that, die, and explode.
Takes a short amount of time, but you need a good understanding of how the game works!