Ever since the first edition of this book was published in 2001, it’s been a favorite of instructors and students because of the clear, concise way it teaches Java and OO programming. Now, this 5th Edition has been updated, reorganized, and improved throughout, to do a better job than ever of teaching core Java to beginners using an IDE (NetBeans or Eclipse) the way today’s professionals do.
You are currently on the Murach site for instructors. To buy this book, please visit our retail site.
Murach’s Java Programming continues the Murach tradition of publishing only the best training books available.”
Ever since the first edition of this book was published in 2001, it’s been a favorite of instructors and students because of the clear, concise way it teaches Java and OO programming. Here are some of the details on how it works for your students.
Your students will be writing their first complete Java applications at the end of chapter 2!
By the end of chapter 5, your students will know how to use Java classes, objects, and methods to write bulletproof applications that use custom methods to validate user input.
Starting from chapter 1, your students will take advantage of the time-saving features that an IDE provides as they use NetBeans or Eclipse to create, compile, run, test, and debug Java applications. The book itself shows how to use NetBeans, but we provide a companion PDF that shows how to use Eclipse.
Section 2, on object-oriented programming, cuts through the mystery of encapsulation, inheritance, and polymorphism so your students can learn how to create and use sophisticated business and data access classes. It also shows how to use two new features of Java 9, the module system and Project Jigsaw, to develop truly modular classes that are easier to use and deploy. At that point, your students will know how to develop real-world, object-oriented, business applications.
In section 3, your students will learn more of the core Java skills that they’ll use all the time, like how to work with arrays, collections, generics, strings, dates, times, file I/O, exceptions, and more! Each chapter in this section is independent of the others, so you can teach these chapters in whatever sequence you prefer.
Section 4 shows the basics of using the JavaFX and Swing APIs to develop attractive graphical user interfaces (GUIs) that handle events and validate data. JavaFX is newer and offers more advanced features, but Swing has been popular for years and is more widely-used.
Section 5 shows your students how to write database classes that map objects to a relational database. First, they’ll learn how to use SQL to work with SQLite databases. Then, they’ll learn how to use JDBC to work with any database.
Section 6 lets you take your students to a new level. Here, they’ll become proficient with the two most exciting features of Java 8, lambda expressions and streams. And they’ll learn how to use threads to make Java applications run more efficiently. Since these chapters are designed as independent modules, you can teach them earlier in the course, if you prefer.
This book has always been a favorite with web developers who use Java servlets and JSPs. Now, this book is becoming a favorite with developers who are moving into Android programming.
That’s because chapters 1-16 deliver the Java skills that they need for Android programming, as well as for servlet/JSP development. So by the time they’re done with the core course, they’re well-prepared for courses on those related subjects. If you’re looking for books on those subjects, our Android and Servlet/JSP texts offer an easy transition for you and your students from our Java Programming book.
The short answer is: Just about everything. But here are 4 ways our book differs from other Java books.
This book has been updated from Java SE 7 to Java SE 9. Here’s a quick summary of all that’s new.
The book still provides great support for NetBeans. But now it also includes support for Eclipse. To do that, the download for the book includes (1) a PDF that shows how to use Eclipse and (2) source code that has been formatted for both IDEs. These materials are included in the supporting instructor files we provide for the book, or you can download them from the book page at our retail site.
Although this book specifically covers Java SE 9, almost all of the core features will work with all previous releases of Java and will continue to work with future releases as well. As for the IDE, we provide materials showing how to use both NetBeans (in the book itself) and Eclipse (in a separate PDF tutorial).
Appendix A (Windows) and Appendix B (Mac OS) explain how to install the software, all of which is free.
Yes!
To make that easier for you, we provide (1) the source code for this book in Eclipse format and (2) a PDF tutorial on using Eclipse with this book. Your students can access these materials by going to the FREE Downloads tab on the book page on our retail site. And you can get them in the supporting instructor files we provide for the book…or you can download them from the retail book page if you prefer.
“If you’re a Java virgin like I was before reading this book, then you’re going to love it. I had a development environment up & running within half an hour and was dabbling with code 15 minutes after that!”
- Andy Bonner, vbcity.com
“One of the things I really like is that this book uses an IDE to teach Java to the next generation of programmers. A lot of books focus on the language itself [as though] an IDE plays no role in learning Java. Any professional programmer will tell you that an IDE is absolutely essential in making you more productive.”
- John Yeary, Java Evangelist
“I loved the way this book is set up. We used this in my Java Programming class, and it just makes everything so much easier and clearer.”
- Posted at an online bookseller
“Another thing I like is the exercises at the end of each chapter. These exercises are a great way to reinforce the main points of each chapter and force you to get your hands dirty.”
- Hien Luu, SD Forum/Java SIG
“I bought this book to brush up on my Java programming skills in preparation for doing some Android programming. This book brought me up to speed really fast.”
- Posted at an online bookseller
“I’m reading the part of the book that discusses the nio package. The information is so clear, it beats what I read in the Java tutorials on the Oracle web site. Once again, a Murach book adds clarity that’s hard to find elsewhere.”
- Steve, Programmer, Denver, Colorado
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
Web applications and mobile apps
The code for a console application
How Java compiles and interprets code
An introduction to Java IDEs
An introduction to NetBeans
How to open, close, and delete a project
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 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 code statements
How to code comments
How to create identifiers
How to declare a class and a main method
How to declare and initialize variables
How to code assignment statements
How to code arithmetic expressions
How to create a String object
How to join and append strings
How to include special characters in strings
How to import classes
How to create objects and call methods
How to view the API documentation
How to print output to the console
How to read input from the console
Examples that get input from the console
How to compare numeric variables
How to compare string variables
How to code if/else statements
How to code while statements
The Invoice application
The Test Score application
How to test an application
How to debug an application
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 Java Shell to test code
How to use the Integer and Double classes
How to use the Math class
How to use the NumberFormat class
The Invoice application with formatting
How to debug a rounding error
The constructors and methods
Examples that work with the BigDecimal class
The Invoice application with BigDecimal objects
How to compare primitive data types
How to use the logical operators
How to code if/else statements
How to code switch statements
The Invoice application with a switch statement
How to code while loops
How to code do-while loops
How to code for loops
The Future Value application
How to code nested loops
How to code break statements
How to code continue statements
The Guess the Number application
How to code static methods
How to call static methods
The Future Value application with a static method
The Guess the Number application with static methods
How exceptions work
How to catch exceptions
The Future Value application with exception handling
How to prevent exceptions from being thrown
How to validate a single entry
How to code a method that validates an entry
The console
The code
Typical test phases
The three types of errors
Common Java errors
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
An introduction to deployment
How to create an executable JAR file
How to deploy the files for an application
How to run a GUI application
How to run a console application
How classes can be used to structure an application
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
How to use NetBeans to work with classes
How to code static fields and methods
How to call static fields and methods
How to code a static initialization block
When to use static fields and methods
The ProductDB class
The user interface and the ProductApp class
Reference types compared to primitive types
How to overload methods
How to use the this keyword
The user interface
The class diagram
The code for the classes
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 use NetBeans to work 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
A Product class that implements the Cloneable interface
A LineItem class that implements the Cloneable interface
An introduction to packages
How to work with packages
How to work with libraries
An introduction to the module system
How to create modules
How to use modules
How to add javadoc comments to a class
How to use HTML and javadoc tags in javadoc comments
How to generate documentation
How to view the documentation for a package
How to declare an enumeration
How to use an enumeration
How to enhance an enumeration
How to work with static imports
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 fill, sort, and search arrays
How to refer to, copy, and compare arrays
How to implement the Comparable interface
The Number Cruncher application
How to work with rectangular arrays
How to work with jagged arrays
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 console
The Invoice class
The InvoiceApp class
How to create a linked list and add and get elements
How to replace, remove, and search for elements
How to use the methods of the Queue and Deque interfaces
A class that uses generics and a linked list to define a queue
The HashMap and TreeMap classes
Code examples that work with maps
The Word Counter application
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 ProductListerApp class
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 dates and times
How to add or subtract a period of time
How to get the time between two dates
How to format dates and times
An Invoice class that includes an invoice date
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
Two interfaces for data access
A class that works with a text file
The console
The ProductManagerApp class
How to connect a binary output stream to a file
How to write to a binary file
How to connect a binary input stream to a file
How to read from a binary file
A class that works with a binary file
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 a custom exception class
How to use exception chaining
An interface that uses custom exceptions
A class that uses custom exceptions
A GUI that displays ten controls
A summary of GUI APIs
The inheritance hierarchy for JavaFX nodes
How to create and display a window
How to work with labels
How to set alignment and padding
How to work with text fields
How to set column widths
How to work with buttons and boxes
How to handle action events
The user interface
The code
How to display an error message in a dialog box
How to validate the data entered into a text field
The Validation class
How to validate multiple entries
An introduction to XML
How to code an FXML application
How to create the files for an FXML application
The FXML file
The controller class
The application class
A user interface with ten controls
A summary of GUI APIs
The inheritance hierarchy for Swing components
How to display a frame
How to set the look and feel
How to work with panels
How to work with buttons
How to handle action events
How to work with labels
How to work with text fields
A summary of layout managers
How to use the FlowLayout manager
How to use the BorderLayout manager
How to use the GridBagLayout manager
How to add padding to a GridBagLayout
How to solve a common problem with the GridBagLayout
The user interface
The code
How to display a dialog box
How to validate the data entered into a text field
The Validation class
How to validate multiple entries
How to work with text areas
How to add scroll bars
How to work with check boxes
How to work with radio buttons
How to add a border and title
How to work with combo boxes
How to work with lists
How to work with list models
The user interface
The code
How a table is organized
How the columns in a table are defined
How tables are related
How to query a single table
How to join data from two or more tables
How to add, update, and delete data in a table
An introduction to SQLite
How to connect to a SQLite database
How to work with a SQLite database
How to execute SQL statements
How to create a SQLite database
Four types of JDBC database drivers
How to download a database driver
How to add a database driver to a project
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 DAO interface
The ProductDB class
Code that uses the ProductDB class
Anonymous classes compared to lambdas
Pros and cons of lambda expressions
A method that doesn’t use lambdas
A method that uses lambdas
The syntax of a lambda expression
How to use the Predicate interface
How to use the Consumer interface
How to use the Function interface
How to work with multiple functional interfaces
How to filter a list
How to map a list
How to reduce a list
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 to install the JDK and NetBeans
How to install the source code for this book
How to install Eclipse
How to install SQLite Manager
How to install the JDK and NetBeans
How to install the source code for this book
How to install Eclipse
How to install SQLite Manager
If you aren’t already familiar with the supporting courseware that we provide for a book, please go to About our Courseware. As you will see, our courseware consists of the end-of-chapter activities in the book, the files in the student download at our retail site, and the instructor’s materials. These components provide everything that other publishers provide, in a way that delivers better results.
If you are familiar with our courseware, here’s a quick summary of the courseware for this book. For a detailed description, please read the Instructor’s Summary .
All the code is provided in both NetBeans and Eclipse formats.
To view the "Frequently Asked Questions" for this book in a PDF, just click on this link: View the questions
Then, if you have any questions that aren't answered here, 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!
This is our site for college instructors. To buy Murach books, please visit our retail site.