There are number of java books in the market for beginners. Every book has good and bad point.
However,some books are very popular in the market. These books are popular because every java expert today in the market has read these books and built their foundation. At their expert level too, they refer these beginners java books.Here i am giving top 5 book in java for all people who want to build their foundation.
5 Beginning Programming with Java For Dummies

Covering everything from basic Java development concepts to the latest tools and techniques used in Java, this book will put would-be programmers on their way to Java mastery Explores what goes into creating a program, how to put the pieces together, dealing with standard programming challenges, debugging, and making it work Updated for the release of the Java SDK 2.0, with all examples revised to reflect the changes in the technology
4 .Java(TM) Puzzlers
A well-liked option with JAVA students and teachers is Java(TM) Puzzlers: Traps, Pitfalls, and Corner Cases. The book by Joshua Bloch, a Jolt Award-winner, has many brainteasers about JAVA coding language and JAVA's core libraries. The book is intended to challenge those who have a working knowledge of the JAVA programming language. The 95 diabolical puzzlers in the book are grouped according to the features employed.
3. Effective Java (2nd Edition)
One of the most popular books on JAVA is Effective Java (2nd Edition). The book is written by a successful Java developer, Joshua Bloch. The strongest selling point of the book is the over 50 tips and best practices for writing a better JAVA code. The book offers advice on effective coding and it offers an insider insight into design choices that have been made in Sun's JAVA libraries over the years. The highly-readable book has 57 free-standing items in 9 chapters and it describes many idioms, patterns and anti-patterns.
2 Thinking in Java (2nd Edition)
Thinking in Java is a great book. This award-winning book by Bruce Eckel is designed for those who want to migrate from other object-oriented languages such as C++ to JAVA. The book covers everything there is to know about JAVA and it brings readers up to speed with the latest features of JAVA 2. The book pays particular attention to object design and it covers different APIs in JAVA 2. Some of the notable topics that are covered include object-design basics, JAVA I/O classes, inheritance and polymorphism, deployment to JAR files, object lifetimes, exception handling, and multi-threading and persistence, among others.
1 Head First Java, 2nd Edition
If you are a person who prefers boring dry lectures over stimulating conversations with witty friends then this book is definitely NOT for you. For all the others, welcome to paradise-Head First Java by Kathy Sierra and Bert Bates! This is one programming book you will enjoy reading with all its funny images and captions it may seem to be a joke book, but mind you this book really know what its trying to achieve- make sure its readers learn Java.
Even after its light hearted handling of the subject, it manages to cover quite a wide range of features in Java and it does all that after clearing the basics like OOP very thoroughly using several analogies which make it so much easier to learn.
Here are some of the other Java features covered by this book-
* Creating graphical user interfaces(using Swing)
* Creating network applications(like creating a chat client and server)
* Exception handling and Threads
* Deploying your aplication using RMI or Java Web Server
But what I loved the most about this book was the “There are no dumb questions” sections after every chapter which somehow managed to answer all the questions popping up in my mind. Apart from that they also have mock interviews , mystery stories which helps to explore the same topic in several different ways .Also the exercises in this book are designed to be part of the reading process itself with interesting crosswords and true/false questions. Thus unlike in other books, you wont get a chance to feel guilty over not solving gigantic exercises :-) .But after all this, I believe if you have not had any programming experience before this might not be the perfect book for you .So in short if you wanna learn java then take this book, besides its comparatively cheaper to.