A combination of ways, spread over many years. And I'm not done learning, so there almost isn't an answer to this question. But to try to hit the highpoints:

1. I bought a copy of Herbert Schildt's "Teach Yourself C" about 1993/1994 or so. Downloaded a shareware C compiler from a BBS and just started writing code.

2. Bought more books on C, C++. Upgraded to Borland Turbo C++ and started writing C++ code. Toyed with writing hobby projects like a D&D character generator, but mostly just worked through examples in the books.

3. Took an "intro to programming logic" class in college.

4. Graduated from the community college and transferred to UNC-W as a CS major. Took "Intro to Pascal Programming" and "Intro to C Programming" and an Assembler course during my first semester or two.

5. Kept studying C and C++ in my spare time, even after dropping out of school. Started dabbling with different libraries like OWL and MFC. Learned some Borland Paradox.

6. Dabbled a bit with other languages for kicks... downloaded freeware or open-source compilers and did at least "hello, world" in all sorts of obscure languages.

7. Went back to the community college to do a degree in computer programming. Took two semesters of C++ and two semesters of RPG/400 plus some other interesting stuff.

7.5 about 1998 or so, started dabbling with Java just a little, but wasn't sold on it.

8. By 2000 I was a modestly competent C/C++ programmer, but with no real world experience and no undergrad degree. But thanks to the dot-com bubble, I was able to get a job as a programmer anyway, once I left the confines of Hicksville and moved to the RTP area.

9. Spent a year or two doing mostly C and C++ and Visual Basic development. Transferred to a different community college to finish the A.S degree I'd dropped out of to move to RTP in 2000. Took two semesters of Java, a semester long class on Enterprise Java, a semester long class on JMS, two semesters of Visual Basic, two semesters of Oracle Pl/SQL and some other stuff I forget now.

9.5 By now I'm writing Java almost exclusively at my day job, developing web-based e-commerce systems.

10. Graduated, went back to that same school to do an A.S. in High Performance Computing. Started my first open source project somewhere in this timeframe. Took 3-4 semesters of classes on MPI programming, OpenMP programming, HPC security, Beowulf Cluster building, an Operating Systems class, etc.

11. graduated, kept working mostly in Java. Have worked mostly in Java ever since, with the exception of a stint at Lulu where I wrote mostly PHP and Python.

12. Started another open source project somewhere back around 2006. Mixed in with all of this going back to the late 90's, BTW, is an interest and association with open-source, including building Mozilla (Mozilla, mind you, not Firefox) from source and reading over it's source, trying to understand it. Tinkered with OpenOffice and some other random crap here and there as well.

12.5 Gave some talks on various topics at the local Java User's Group, Linux User's Group, etc.

13. About a year ago, launched the open-source project that I'm hoping to build a startup around. This time it's built in Groovy and I'm moving more and more towards Groovy, while still writing Java at my $DAYJOB.

14. Organize the TriJVM Hack Night meetup, where various people get together to hack on various "stuff" in any of the many JVM languages. I usually use the Hack Nights as an opportunity to spend a couple of hours working on Scala or Clojure. I'm really starting to get into Clojure.

15. Started writing overly long and detailed answers to questions on HN when I could be coding. Shame on me.

As far as books go, there have been many over the years, but I always got a lot of mileage out of those "Dietel and Dietel" books. People seem to either love those or hate them, but they seemed pretty good to me. Bruce Eckel's "Thinking in C++" was a good one as well. The Robert Sedgewick books are good for algorithms stuff. I own a copy of SICP, but still haven't gotten around to working through it. But I will, one day... yes, one day I will. After that I'll tackle TAOCP (if I live long enough!)

There are all sorts of opportunities and avenues to learn, so just take advantage. I also forgot to mention going to Users Group meetings (as an attendee) and I learned a lot from many Tri-JUG meetings or Tri-LUG meetings (among others.) And of course there are tons of videos and great lectures up on on Youtube and other sites. Lately I've been going through that Stanford/Google one on Data Mining and reading the Head First Statistics book.

If there's a point to all this, I'd say it's "Just keep learning."