I can't work out the reason behind why the thrown up spear changes its direction midair. Why? (Suppose there is no air drag.)
It has to do with aerodynamic stability. The weight of the Javelin tends to be towards the front where the spearhead is. The long shaft then allows for a center of pressure which gets pulled behind the center of gravity.
Having a center of pressure behind the center of gravity is a basic criteria for longitudinal static stability. What results is that when the spear is in flight, any angle relative to the respective wind (see angle of attack of an airfoil) will cause a Normal Force on the spear which will orient the spear to be in line with the relative wind (i.e. the direction of movement assuming no actual wind).
This idea is similar to that of why arrows have tail feathers and why airplanes have tails - they pull the center of pressure rearward behind the center of gravity.
Moreover, if the spear where short enough it is possible that the center of pressure be in front of the center of gravity which would result in the spear tumbling in the air instead of self-orienting itself.