Good Java Books for Beginners?
nobody69 asks: "During the spring I took a C++ class at the local junior college and, frankly, the textbook sucked. However, I remembered hearing Good Things about 'Practical C++ Programming' on /., so I picked it up and found it to be a great resource, especially since it was about half the price of the text. But I'm starting Java soon, so I was wondering if there was any Java equivalent - something with lots of short, to-the-point examples and good explanations. 'Practical C++ Programming' also had some exercises at the end of each chapter, whicch would be nice, but aren't necessary."
I really liked the previous editions of O'Reilly's Java in a Nutshell and Java Examples in a Nutshell. My job doesn't involve Java (thank the gods! :), so I haven't had much use for them, but still they sit on my bookshelf, and my co-workers that do program in Java have either borrowed both of them repeatedly or have copies of their own. (The same author, David Flanagan, is also the author of a couple of O'Reilly's JavaScript books, but that's not what you're looking for here.)
(Ok sorry I can't resist -- my favorite lame Java bashing line: "Java has all the graceful simplicity of a systems language like C with the incredible performance of a scripting language like Python. That is to say, it's ugly as hell & slow as shit." Personally, I say if you're better off going with ugly but fast, like C, or pretty but slow, like Python. Java is the worst of all worlds, remarkable mainly for the dexterity with which Sun's marketing department has shoved this terrible language down our collective throats.)
But, like I say, I'm trying to be constructive here :). Less sarcastically, the Nutshell books are great, both as a learning tool and as a refernce later, after you're comfortable with the language. The same applies with other books in the series too.
DO NOT LEAVE IT IS NOT REAL
However, Java is a different deal all together. First of all, if you are familiar with C++ you now about 90% of Java right of the bat. So you don't really need a "from scratch" Java book. All you really need is reference material, and some basic guides on how key things work in the JVM, like threading, synchronization, etc.
My recommendation is the web on this one. Download the latest JDK (1.3 or 1.4). That is full of great references, API's, HOWTO's and guides. This will be the source of 95% of your Java knowledge.
Next, I'd start checking out C/C++ User's Journal's Java Solutions. You can subscribe to the magazine, but frankly I'd stick to the online version. These guys are C++ freaks who talk about java from the C++ perspective, so you will feel at home with the discussions there.
The only books that I would recommend, are for specific applications. For GUI work, get O'Reilly's Java Swing, and Topley's Core Swing Advanced Programming. Either one will do; they are both excellent. For Serlvet's, O'Reilly's Java Servlets is OK, but slightly out of date (maybe mine is and they have updated). Also, Professional JSP by Wrox is excellent for both serlvet and JSP work (even touches on EJB).
What is interesting for me about Java, is that I find myself using online resources much more than I ever do with C/C++ applications. Java documentation is so standardized (javadoc) that it lends well to this approach.
Someone you trust is one of us.
A good beginner's book on Java is Wrox's Beginning Java 2, by Ivor Horton. It has a couple of chapters that are not well put together (JDBC, I/O), but the book is really good at introducing you to the syntax, the mode of thought, etc, particularly for someone who does not have much programming experience.
Bruce Eckel's Thinking in Java is a great book for introducing C/C++ programmers to Java, and some of the coverage is excellent. However, some of what Eckel says is just plain wrong, particularly his coverage of Servlets. But that's okay, since you'll want subject/API-specific books by the time you get to those areas anyway.
Good servlet/JSP coverage is quickly had from the Wrox books: Professional JSP 2nd ed., Professional Java Server Programming J2EE ed., etc. Also, staples like Jason Hunter's Java Servlet Programming and Hans Bergsten's JavaServer Pages from O'Reilly are quite good, though less bang (ie, pages) for the buck.
Java in a Nutshell is an essential reference, but a really sucky introductory tutorial.
The best JDBC book I know of is the JDBC API Tutorial and Reference, 2nd ed. Avoid O'Reilly's JDBC book, it just isn't anywhere near as good, and the examples don't make much sense.
I've heard good things about Java IO and Java Networking by Elliott Rusty Harold from O'Reilly, but I've not had the chance to pick them up. Brett McLaughlin's Java and XML is good, but wait for the next edition.
If you are (or become) serious about Java (or any other OO language), you would do yourself a HUGE favor to pick up the Gang of Four's Design Patterns.
---Good luck!
As a complete beginner at programming, I found two books particularly useful for coming to grips with Java and object-oriented programming generally. One which has already been mentioned is the Ivor Horton book "Beginning Java 2" published by Wrox Press. Another is "Just Java 2" by Peter Van Der Linden. If you're already an experienced programmer, you should probably go with Bruce Eckel's "Thinking in Java".
There is no single book that is going to do it for everyone, and not all people learn the same way. You might as well spend the time reading over the first few chapters of several books, and figure out which writers you retain information with, which ones present ideas in ways that you can understand them, and which ones were put out by companies looking to expand their booklists. Also, you might as well get used to the idea that you'll probably want two books (at least), one which is a beginner's book and a second which will probably act as a complete reference. Their roles will be different -- one's purpose will be to get your feet wet and the other's will be for speedy knowledge lookup once you know what you're doing. Chances are, depending on what type of programming you want to get into, you might need a third Java reference specifically for that topic (ie: servlets, database aps, etc.).
Stay away from For Dummies books. I picked up one that had typos in the code listings that no "Dummy" would have been able to figure out (like, forgetting to pass an argument by its address -- that's C++ related but you get my drift, hopefully).
I'm personally very wary of books that attempt to be both beginner's books AND complete references (Deitel and Deitel in particular put me on edge -- they try to do both and come up short in both, they tend to be too involved for beginner's level and too jumbled and disorganized to be decent reference books, imo).
I think multiple texts with multiple points of view are really good for putting a language into perspective. Besides, you'll also get exposed to different coding styles and techniques, which will be useful in the long run. For this reason, don't discount online references. They probably aren't the greatest primary material, but the more examples you're exposed to, the better.
--------
Bleah! Heh heh heh... BLEAH BLEAH!!! Ha ha ha ha...
Despite its bad reviews on Amazon, Mastering Java 2 is an excellent resource for beginner to export.
It starts assuming you are familiar with programming concepts, but not with Java, and covers the bases from there. The first 8 chapters or so are dedicated to the groundwork: Java syntax, objects, concepts, all the way through to threading. There is extensive coverage of the AWT and (IIRC) Swing, and a good rundown on IO streams later in the book. It also introduces RMI, CORBA and other technologies enough to impart some understanding so you can get going on your own or with 'net references.
i-name =twylite [http://public.xdi.org/=twylite], see idcommons.net