You need to get a train to Matsumoto and transfer to the Oita line for a train heading to Hakuba (you might have to change at Shin Omachi station). It will probably take you about 5 hours to get to Matsumoto from Osaka airport, or from Kyoto.
This is the cheapest and quickest method. You first need to get a bus to Matsumoto, then from there catch a train to Hakuba.Click on this Osaka/Kyoto to Matsumoto Alpico Bus link.
