The Pilum was a javelin used by Roman armies. It was the Mid-Range weapon of the Roman Centurion.
The pilum had an iron shank with a pyramidal head, The shank was secured to a wooden shaft, either by means of a socket or a tang. The pilum was about 2 meters (6.6 feet) long and weighed between 2 and 5 kilograms (4.4 to 11 lbs).
Though it could be used as a melee weapon, the pilum was primarily a throwing spear. The pilum had a maximum distance of around 100 feet (30 meters) through the effective range was 50 to 65 feet (15 to 20 meters). The pilum was designed so that the shank bent or broke off from the wooden shaft on impact to prevent the opponent from throwing it back at the Romans or to get stuck into enemy shields. This was achieved by replacing the lower peg that connected the spearhead to the shaft: by having the bottom peg be made of wood, it would break and bend on impact. The top peg would still be made of iron to make sure the spearhead didn't just fall off the shaft entirely. The weight of the pilum would make the enemy shield too cumbersome to be used.
The use of the pillim likely differed according to the enemies the Romans encountered. Against Barbarian infantry or cavalry, which depended on the shock of a charge to break the lines, the whole Roman front would have advanced slowly and waited for the enemy to begin their rush before throwing their javelins. With the whole weight of the enemy bearing down on them and running into range, the whole formation could launch their pila, confident that even the back ranks, at first seemingly out of range, would hit the enemy as it ran forward. The momentum of the enemy charge would work against the barbarian ranks as this would add to the penetrative force of the pilum. Once the volley was loosed, the front ranks might have time to rush forward in a short counter-charge. Against Greek and Hellenistic forces, which advanced slowly to maintain the cohesion of their hedge of spears, the front ranks of the Roman infantry would throw their pila, charge forward, and engage, whilst the rear ranks would wait for the space to open up before running forward and casting their own javelins and then joining their front rank comrades in the scrum.
The pilum likely provided greater advantage against an enemy running into the legions; their momentum working against them. At the battle of Philippi (42 BC) the veteran legions of both sides neglected the use of the pilum and advanced directly into hand-to-hand fighting. In part this was due to the respect both sides had for each other, this being a battle in a Roman civil war. The pilum, being a ranged weapon, brought down both the exceptional and unexceptional soldier alike, and the two sides desired to test their mettle. But, if the volleys of pila provided significant advantage in a contest between legions, it is unlikely the two sides would have resolved not to use them. Thus, the pilum seems to have been a more useful weapon against barbarian forces rather than against similarly equipped and disciplined heavy infantry. This all is of course speculative, our sources deriving primarily from men who did not serve and observed the Roman army from the outside. -Adrian
The Samnites are credited with being the first to use the Pilum and Scutum in combat, only for the Romans to conquer the Samnites and copy this tactic.
Velites were light units within the Roman army that specialized in throwing javelins; primarily because these soldiers could not afford superior weapons as they were from the lowest income backgrounds.  Auxilia also would use javelins within the Roman army, although not exclusively. Peltists were the Greek equivalent to these units.
The Marian Reforms made the Pilum the standard javelin of the Roman army; before this, the pilum did not have the wooden peg that made the spearhead bend, and so these were just normal heavy javelins.
The Battle of Beneventum (275 BC) confirmed that heavy pilum could kill or rout Elephants if thrown in large volleys.