Our Ironclad Guarantee
You must be satisfied. Try our print books for 30 days or our eBooks for 14 days. If they aren't the best you've ever used, you can return the books or cancel the eBooks for a prompt refund. No questions asked!
We’ve designed Murach’s Beginning Java with NetBeans specifically for beginning programmers and programmers with limited experience who want to learn Java at a professional level. By the time you finish this book, you’ll have all the core Java skills that you need to move on to web or Android programming.
Go to our instructor's site to learn more about this book and its instructor's materials.
At long last, a Java book written with understandable text, ready-to-run code, and some of the best exercises in print! This book has a no-nonsense style, with an expert perspective on the big picture.”
Section 1 presents a 6-chapter Java course that gets you off to a great start. This section works for complete beginners as well as experienced programmers because it lets you set your own pace. If you’re a beginner, you’ll move slowly and do all the exercises. If you have some experience, you’ll move more quickly and do the exercises that you choose.
From the start, you’ll be using the NetBeans IDE because that will help you learn faster. Then, by chapter 3, you’ll be developing applications that use classes from the Java API. By chapter 4, you’ll be developing object-oriented applications that use your own classes. By chapter 5, you’ll be using a 3-tier architecture to structure your object-oriented applications like a professional. And by chapter 6, you’ll be using the best practices for testing and debugging your applications.
In section 2, you’ll expand upon what you learned in section 1 by mastering more of the core Java skills that you’ll use all the time. That means you’ll learn new skills, like how to work with strings and arrays. But you’ll also learn more about topics that were introduced in section 1, like working with primitive types and operators and coding control statements. These are the essentials that you need for section 3.
This book has you creating simple object-oriented programs right from the start in section 1. Then, section 3 cuts through the mystery of inheritance, interfaces, polymorphism, and the factory pattern so you can learn how to create and use sophisticated business and data access classes. When you finish this section, you’ll know how to develop real-world, object-oriented, business applications.
Like section 2, section 4 lets you expand your core Java skills in new ways. To be specific, it teaches you how to work with collections, generics, lambdas, dates, times, exceptions, file I/O and threads. Because each chapter in this section is independent of the others, you can add these skills to your resume whenever you need them.
When you complete sections 1-4, you’ll have all the Java skills you need to start learning web and Android programming. But there’s more!
The 4 chapters in section 5 introduce you to the skills that a professional Java programmer uses to develop desktop applications. To start, these chapters show you how to create a MySQL database for an application and how to write the Java code that works with the data in this database. Then, these chapters show how to develop a graphical user interface (GUI) for the application.
These chapters are designed to give you a better appreciation for what real-world Java programming is like, whether that be desktop, web, or Android programming. That, in turn, will help you decide what to learn next to build your Java career.
Like all of our books, this one has the distinctive features that make Murach books so effective. But here are a few of the benefits that are specific to this book:
For the past 13 years, we’ve often had true beginners tell us that they like our Java book overall, but they also find it overwhelming at times. (As one reviewer of the first edition put it, “It’s not for the faint of heart!”) They’ve requested more explanation of certain topics, more examples, and a more relaxed pace.
So that’s what Murach’s Beginning Java delivers. We took a hard look at the way we present material in Murach’s Java Programming and rearranged topics with beginners in mind. We introduced object-oriented programming earlier so that the OOP mindset would become natural right at the start. We added more explanation on core programming concepts, like working with classes, numbers, strings, and control structures. We slowed the pace some, breaking the material down into shorter chapters that would be easier to master. We added more examples to guide beginners through the code and more exercises to let them practice what they’ve learned.
In short, we now have the ideal book for you if you’re new to programming and Java.
Unlike many Java books, this book shows you how to use an IDE for developing Java applications. That’s how Java programming is done in the real world because an IDE is loaded with time-saving development tools. So that by itself will help you learn faster.
For this book, we’ve chosen the NetBeans IDE because it’s free, widely used, and easy for beginners to set up and use. So chapter 1 shows you how to get started with this IDE, and subsequent chapters present new NetBeans skills whenever they’re useful.
Unlike many Java books, this one gets you going with object-oriented programming (OOP) from the start. By chapter 3, you’ll be developing applications that use the classes from the Java API. By chapter 4, you’ll be doing object-oriented programming with your own classes. And by chapter 5, you’ll be using a 3-tier architecture to structure your object-oriented applications like a professional.
That means that you’ll be using and thinking objects from the start...the way Java was designed to be used.
Unlike many Java books, this one focuses on the Java features that you will use every day on the job. As a result, it doesn’t waste your time by presenting Java features that you probably won’t ever need.
This also means that all of the examples in this book are drawn from real-world applications. This is especially apparent in the object-oriented chapters, where most competing books resort to unrealistic examples that are difficult to apply on the job.
One of the goals of this book is to present all of the core Java skills that you need to start learning Java web programming and Android programming. That’s why we made sure that this book covers all the prerequisites you need for Murach’s Java Servlets and JSP (our Java web programming book) and Murach’s Android Programming. But regardless of what Java book or course you go on to, we haven’t seen another beginning Java book that prepares you so thoroughly.
This book is for anyone who wants to learn the core features of the Java language, especially the features that you need to learn web or Android programming. It is especially designed for those:
This book is perfect for developers who are moving into programming Android apps or Java web applications. The first four sections deliver the core Java skills that you need, whether you’re looking for a refresher or a first course in Java.
Java SE 8 is the current version of Java and the one that this book shows how to use. However, since all versions of Java are backwards compatible, the code and skills presented in this book will work with later versions too.
As you can tell from its title, this book shows you how to use the NetBeans IDE to code, test, and debug applications. It’s a great tool for beginners that’s easy to use, free, popular, and that runs on all operating systems.
You can download Java and its documentation for free from the Oracle website. Likewise, you can download NetBeans for free from the NetBeans website. To make this easier for you, Appendix A (for Windows) and Appendix B (for the Mac) explain the procedures you will use to download and install both pieces of software.
If you already have experience with Eclipse or want to use it instead, please note that we have an Eclipse version of this book called Murach’s Beginning Java with Eclipse. The only difference between that book and this one is the IDE.
Since web programming is one of the primary uses of Java, we also offer a book on web programming called Murach’s Java Servlets and JSP (3rd Edition). It shows you how to use Java servlets and JavaServer Pages as you develop professional web applications. As you read that book, you’ll discover that Java web programming requires most of the skills that are presented in sections 1-4 of Murach’s Beginning Java with NetBeans.
Another primary use of Java today is developing Android apps for tablets and smart phones. So we also offer a great first book on that subject, Murach’s Android Programming (2nd Edition). Like our Servlets and JSP book, this book assumes that you have the skills that are presented in sections 1-4 of Murach’s Beginning Java with NetBeans.
Another Murach book that you should be aware of is Murach’s Java Programming. This book has been one of the best-selling Java books since its first edition in 2001, but it isn’t a beginning book. As a result, it is organized differently, moves faster, goes into greater depth, and presents some additional subjects, particularly on GUI programming and handling data. In general, though, you shouldn’t need this book if you have Murach’s Beginning Java.
“If developers would rather not work through hundreds of pages but would prefer a hands-on experience in which they write small programs that quickly teach the language in a series of graduated projects, then Murach’s Beginning Java is the book I recommend.”
- Andrew Binstock, Editor-in-Chief, Java Magazine; from a review in the January/February 2016 issue
“Great book for working with Java and NetBeans. In addition to Java basics, it presents essential Java skills against the core APIs in an easy-to-understand format.
“Over the years I have used Eclipse, IntelliJ IDEA, and NetBeans IDEs for projects and have always had a preference for NetBeans due to its ease of use and intuitiveness. This book covers Java in sync with NetBeans by the best means throughout. If you plan on writing any software with Java, consider using the NetBeans IDE as well as referencing/buying this book.”
- Robert Liguori, posted at Amazon
“It’s Hard to Learn What You Already Know: I mean, the hardest questions to answer are the ones you don't know enough to ask, and the hardest things to learn are the things you think you already know. [But] every time I open this book I learn something new and useful. And it's not always what I was looking for, which is a good thing.”
- Phil Norcross, Writer, Editor, Webmaster, & Server Administrator; from a review posted on his blog and at Amazon
“At the end of every chapter, there are a set of hands-on exercises that let you practice the concepts in that chapter. So many other books either don't have practice problems at all, or if they do, they are so open-ended and time-consuming that it is hard to know if you got them right. Murach provides practice code that you download from their website. The problems typically involve using the IDE to make simple code modifications, and then running and debugging your changes. This is an important hands-on approach, since it is not enough to learn a new language just by reading about it.”
- Bruce Alspaugh, St. Louis Java Users Group
“A Must-Have Book for Your Library: I highly recommend this book for any developer, regardless of experience or skill level.”
- Posted at Amazon
View the table of contents for this book in a PDF: Table of Contents (PDF)
Click on any chapter title to display or hide its content.
Java timeline
Java editions
How Java compares to C++ and C#
Two types of desktop applications
Two types of web applications
Mobile apps
The code for a console application
How Java compiles and interprets code
Introduction to IDEs for Java development
How to open a project
How to open a file in the code editor window
How to compile and run a project
How to use the Output window with a console application
How to work with two or more projects
How to close or delete a project
How to code a class
How to code a main method
How to code statements
How to code comments
How to print output to the console
How to create a new project
How to work with Java source code and files
How to use the code completion feature
How to detect and correct syntax errors
How to declare and initialize variables
How to assign values to a variable
How to code arithmetic expressions
How to declare and initialize String variables
How to join strings
How to include special characters in strings
The user interface
The CodeTesterApp class
How to import classes
How to create an object from a class
How to call a method from an object
How to call a method from a class
How to view the documentation for the Java API
How to use the Scanner class to get input
How to convert strings to numbers
A class that reads input from the console
How to convert numbers to formatted strings
A class that prints formatted numbers to the console
How to compare numbers
How to compare strings
How to code a while loop
How to code an if/else statement
The user interface
The code
The user interface
The code
How encapsulation works
The relationship between a class and its objects
How to use NetBeans to create a new class
The Product class
How to code instance variables
How to code constructors
How to code methods
How to create an object from a class
How to call the methods of an object
The ProductDB class
How to code and call static fields and methods
When to use static fields and methods
The user interface
The ProductApp class
Reference types compared to primitive types
How to overload methods
How to use the this keyword
The Product class with overloading
How the three-tier architecture works
How to work with packages
How to use NetBeans to work with packages
The user interface
The class diagram
The LineItem class
The LineItemApp class
Typical test phases
The three types of errors
Common Java errors
How to determine the cause of an error
A simple way to trace code execution
How to set and remove breakpoints
How to step through code
How to inspect variables
How to inspect the stack trace
The eight primitive data types
How to declare and initialize variables
How to declare and initialize constants
How to use the binary operators
How to use the unary operators
How to use the compound assignment operators
How to work with the order of precedence
How to work with casting
How to use the Math class
How to use the BigDecimal class
How to fix rounding errors
The user interface
The code
How to compare primitive data types
How to use the logical operators
How to code if/else statements
How to code switch statements
A new if/else statement for the Invoice application
How to code while loops
How to code do-while loops
How to code for loops
How to code break and continue statements
How exceptions work
How to catch exceptions
The user interface
The code
How to create strings
How to join strings
How to append data to a string
How to compare strings
How to work with string indexes
How to modify strings
How to create a StringBuilder object
How to append data to a string
How to modify strings
The user interface
The StringUtil class
The Main class
How to create an array
How to assign values to the elements of an array
How to use for loops with arrays
How to use enhanced for loops with arrays
How to work with two-dimensional arrays
How to fill an array
How to sort an array
How to search an array
How to create a reference to an array
How to copy an array
How to compare two arrays
The user interface
The Main class
How inheritance works
How the Object class works
How to create a superclass
How to create a subclass
How polymorphism works
The console
The Product, Book, and Software classes
The ProductDB class
The ProductApp class
How to cast objects
How to compare objects
How to work with the abstract keyword
How to work with the final keyword
A simple interface
Interfaces compared to abstract classes
How to code an interface
How to implement an interface
How to inherit a class and implement an interface
How to use an interface as a parameter
How to use inheritance with interfaces
How to work with default methods
How to work with static methods
The console
The ProductReader interface
The ProductDB class
The ProductApp class
An introduction to GUI programming
How to code an inner class
How to code an anonymous class
How to declare an enumeration
How to use an enumeration
How to enhance an enumeration
How to work with static imports
How to add javadoc comments to a class
How to use HTML and javadoc tags in javadoc comments
How to use NetBeans to generate documentation
How to view the documentation
A comparison of arrays and collections
An overview of the Java collection framework
An introduction to generics
How to create an array list
How to add and get elements
How to replace, remove, and search for elements
How to store primitive types in an array list
The user interface
The Invoice class
The InvoiceApp class
An introduction to lambdas
A method that doesn’t use a lambda expression
A method that uses a lambda expressions
How to use the Predicate interface
The date/time API prior to Java 8
The date/time API for Java 8 and later
How to create date and time objects
How to get date and time parts
How to compare dates and times
How to adjust date/time objects
How to add or subtract a period of time
How to format dates and times
An Invoice class that includes an invoice date
The exception hierarchy
How exceptions are propagated
How to use the try statement
How to use the try-with-resources statement
How to use the methods of an exception
How to use a multi-catch block
How to use the throws clause
How to use the throw statement
How to create your own exception class
How to use exception chaining
A package for working with directories and files
Code examples that work with directories and files
How files and streams work
A file I/O example
How to work with I/O exceptions
How to connect a character output stream to a file
How to write to a text file
How to connect a character input stream to a file
How to read from a text file
A class that works with a text file
The console
The Main class
How threads work
Typical uses for threads
Classes and interfaces for working with threads
The life cycle of a thread
Constructors and methods of the Thread class
How to extend the Thread class
How to implement the Runnable interface
How to use synchronized methods
When to use synchronized methods
How a table is organized
How the tables in a database are related
How the columns in a table are defined
What MySQL provides
Ways to interact with MySQL
How to open a database connection
How to enter and execute a SQL statement
How to drop, create, and select a database
How to create a table and insert data
How to create a user and grant privileges
How to select data from a table
How to insert, update, and delete rows
An introduction to database drivers
How to connect to a database
How to return a result set and move the cursor through it
How to get data from a result set
How to insert, update, and delete data
How to work with prepared statements
The DBUtil class
The ProductDB class
Code that uses the ProductDB class
A summary of GUI toolkits
The inheritance hierarchy for Swing components
How to display a frame
How to add a panel to a frame
How to add buttons to a panel
How to handle a button event
A summary of layout managers
How to use the FlowLayout manager
How to use the BorderLayout manager
How to create a model for a table
The ProductTableModel class
How to create a table
How to get the selected row or rows
How to add scrollbars to a table
How to display a message
How to confirm an operation
The user interface
The ProductManagerFrame class
How to work with labels
How to work with text fields
An introduction to the GridBagLayout manager
How to lay out components in a grid
How to add padding
How to avoid a common pitfall
How to create a custom dialog
How to pass data between a dialog and its parent
The user interface
The ProductForm class
Two methods that use the ProductForm class
A common problem
How to solve the problem
How to install the JDK and NetBeans
How to install the source code for this book
How to install MySQL and MySQL Workbench
How to create the database for this book
How to restore the database for this book
How to install the JDK and Netbeans
How to install the source code for this book
How to install the MySQL Community Server
How to install MySQL Workbench
How to create the databases for this book
How to restore the databases
How to update the password for the root user
If you’re a beginner and want to see whether this book is right for you, please download and read the first chapter. You can also download the book applications and exercises, so you can do the exercise at the end of chapter 1 and work with some sample code.
This chapter gets you started by introducing Java programming and showing you how to use NetBeans to create, edit, compile, and run Java projects.
Chapter 1 PDF (1,544Kb) Download Now
This download includes:
All of the code is stored in NetBeans projects that are ready to be used with the NetBeans IDE. Appendix A in the book describes how to install these files on a Windows system, and Appendix B describes the installation process on a Mac.
Exe file for Windows (2Mb) Download Now
Zip file for any system (1.9Mb) Download Now
On this page, we’ll be posting answers to the questions that come up most often about this book. So if you have any questions that you haven’t found answered here at our site, please email us. Thanks!
To view the corrections for this book in a PDF, just click on this link: View the corrections
Then, if you find any other errors, please email us so we can correct them in the next printing of the book. Thank you!
For orders and customer service:
1-800-221-5528
Weekdays, 8 to 4 Pacific Time
If you're a college instructor who would like to consider a book for a course, please visit our website for instructors to learn how to get a complimentary review copy and the full set of instructional materials.