I've been working in software for the better part of two decades, and from my experience the answer is... all of the above and more. But ultimately I don't believe anyone can give you a formula that will work specifically for you since only you know you the best.
For me personally it's reading every pertinent book, magazine or blog post I can get my hands on, endless sandbox experiments, side projects when I can, and meeting other developers face-to-face. YMMV.