My Cart (0)

Customer Service 1-800-221-5528

Murach’s Java Programming (5th Edition)

by Joel Murach
23 chapters, 777 pages, 326 illustrations
Published July 2017
ISBN 978-1-943872-07-7
Print: $59.50
eBook: $54.50
Print + eBook: $72.00

This is the 5th Edition of our best-selling core Java book. (There is a newer version). Since 2001, it has been used by thousands of beginning and experienced programmers to master the core Java skills that are needed to create desktop, web, and mobile applications. Now revised to cover Java SE 9 and updated throughout, it focuses on today’s best practices, including using an IDE for all phases of program development …a professional practice that most other Java books ignore.

College Instructors

Go to our instructor’s site to learn more about this book and its instructor’s materials.

 

I love your Java book. It cuts right to the essential information, providing the perfect balance between too many details and too little information. I bought another well-known Java book, but I spent several hours trying to learn what I learned from your book in about 45 minutes."

Posted at an online bookseller

  • About this Book
  • Table of Contents
  • FREE Downloads
  • Book FAQs
  • Corrections
  • Reviews

What to expect from this book

Get a quick start

You’ll be writing your first complete Java applications at the end of chapter 2!

Build realistic applications

By the end of chapter 5, you’ll know how to use Java classes, objects, and methods to write bulletproof applications that use custom methods to validate user input. That gets you off to a fast start in Java whether you’re a beginner or have years of programming experience.

Work more efficiently by using an IDE

Starting from chapter 1, you’ll take advantage of the time-saving features that an IDE provides as you use NetBeans or Eclipse to create, compile, run, test, and debug Java applications. The book itself shows how to use NetBeans, but there’s a PDF in the free download for this book that shows how to use Eclipse.

Make sense out of object-oriented programming

Section 2, on object-oriented programming, cuts through the mystery of encapsulation, inheritance, and polymorphism so you can learn how to create and use sophisticated business and data access classes. It also shows you 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 the end, you’ll know how to develop real-world, object-oriented, business applications.

Expand your core Java skills

In section 3, you’ll learn more of the core Java features that you’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 add these skills to your resume whenever you need them.

Create user-friendly GUIs

Section 4 shows you 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.

Work with databases like a pro

To complete your OOP training, section 5 shows you how to write database classes that map objects to a relational database. First, you’ll learn how to use SQL to work with SQLite databases. Then, you’ll learn how to use JDBC to work with any database.

Take your skills to a new level

Section 6 adds to your professional skills. So you’ll become proficient with the two most exciting features of Java 8, lambda expressions and streams. And you’ll learn how to use threads to make your applications run more efficiently.

Who this book is for

This book is for anyone who wants to learn the core features of the Java language. It works:

    • if you have an aptitude for problem-solving but no programming experience at all
    • if you have programming experience with another language
    • if you already know an older version of Java and you want to update your skills
    • if you’ve already read 3 or 4 other Java books and still don’t know how to develop a real-world application

If you want to go into mobile or web development…

This book is a favorite among developers who are moving into programming Android apps or Java web applications. Chapters 1-16 deliver the core Java skills that you need, whether you’re looking for a first course in Java or a refresher.

What’s NEW in this edition

This book has been updated from Java SE 7 to Java SE 9. Here’s a quick summary of all that’s new:

  • New chapter on lambda expressions and streams
  • New chapter on the Java 8 date/time API
  • New chapter on JavaFX
  • New coverage of the popular SQLite database
  • New material on using Java 9’s JShell to interactively test code
  • New material on using Java 9’s module system and Project Jigsaw
  • New downloadable PDF that shows how to use Eclipse with this book
  • New source code files in Eclipse format

What software you need

This book teaches you how to develop Java applications using:

  • the Java Platform Standard Edition (Java SE)
  • the top IDEs for Java programming: NetBeans (shown in the book) and Eclipse (covered in a downloadable PDF)

Although this book 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.

You can download Java for free from the Oracle website. Likewise, you can download the IDEs for free from the NetBeans website or the Eclipse website.

Companion books for web and mobile developers

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). This book requires most of the skills that are presented in chapters 1-16 (sections 1-3) of our Java Programming book.

Another primary use of Java today is developing Android apps for tablets and smart phones. So we also offer a book on that subject, Murach’s Android Programming (2nd Edition). Again, this book requires that you have most of the skills presented in chapters 1-16 of our Java Programming book.

What people say about this book

“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 on Java focus on the language itself. This would have the appearance that an IDE plays no role in learning Java [but] any professional programmer will tell you that an IDE is absolutely essential in making you more productive.”
- John Yeary, Java Evangelist

“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

“Ever have someone come in your office with a Java question, and you reach for a certain book that you know has the answer in it? When needing assistance with the core features of Java, Murach’s Java Programming is the resource that supplies these answers, both quickly and completely. If this book isn’t on your bookshelf, you should get it there.”
- Robert Liguori, Tech Center Java User Group

“I love the 2-page style that you use in your Java book. It is such a great way to organize the lessons. I already have another Murach book picked out for when I am done with this one.”
- Dave Merton, Director of Development, Connecticut

“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

“If I’d seen this book first, I would not have wasted money (and time) on 6 other books!”
- Posted at an online bookseller

“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.

Section 1 Essential skills

Chapter 1 An introduction to Java

An overview of Java

Java timeline

Java editions

How Java compares to C++ and C#

Types of Java applications

Two types of desktop applications

Web applications and mobile apps

An introduction to Java development

The code for a console application

How Java compiles and interprets code

An introduction to Java IDEs

How to use NetBeans to work with existing projects

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 use NetBeans to develop new 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

Chapter 2 How to write your first Java applications

Basic coding skills

How to code statements

How to code comments

How to create identifiers

How to declare a class and a main method

How to work with numeric variables

How to declare and initialize variables

How to code assignment statements

How to code arithmetic expressions

How to work with string variables

How to create a String object

How to join and append strings

How to include special characters in strings

How to use classes, objects, and methods

How to import classes

How to create objects and call methods

How to view the API documentation

How to use the console for input and output

How to print output to the console

How to read input from the console

Examples that get input from the console

How to code simple control statements

How to compare numeric variables

How to compare string variables

How to code if/else statements

How to code while statements

Two illustrative applications

The Invoice application

The Test Score application

How to test and debug an application

How to test an application

How to debug an application

Chapter 3 How to work with the primitive data types

Basic skills for working with data

The eight primitive data types

How to declare and initialize variables

How to declare and initialize constants

How to code arithmetic expressions

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 Java classes to work with numbers

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

How to use the BigDecimal class

The constructors and methods

Examples that work with the BigDecimal class

The Invoice application with BigDecimal objects

Chapter 4 How to code control statements

How to code Boolean expressions

How to compare primitive data types

How to use the logical operators

How to code if/else and switch statements

How to code if/else statements

How to code switch statements

The Invoice application with a switch statement

How to code loops

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 and continue statements

How to code break statements

How to code continue statements

The Guess the Number application

Chapter 5 How to code methods, handle exceptions, and validate data

How to code and call static methods

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 to handle exceptions

How exceptions work

How to catch exceptions

The Future Value application with exception handling

How to validate data

How to prevent exceptions from being thrown

How to validate a single entry

How to code a method that validates an entry

The Future Value application with data validation

The console

The code

Chapter 6 How to test, debug, and deploy an application

Basic skills for testing and debugging

Typical test phases

The three types of errors

Common Java errors

A simple way to trace code execution

How to use NetBeans to debug an application

How to set and remove breakpoints

How to step through code

How to inspect variables

How to inspect the stack trace

How to deploy an application

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

Section 2 Object-oriented programming

Chapter 7 How to define and use classes

An introduction to classes

How classes can be used to structure an application

How encapsulation works

The relationship between a class and its objects

How to work with a class that defines an object

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 and use static fields and methods

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 Product Viewer application

The ProductDB class

The user interface and the ProductApp class

More skills for working with objects and methods

Reference types compared to primitive types

How to overload methods

How to use the this keyword

The Line Item application

The user interface

The class diagram

The code for the classes

Chapter 8 How to work with inheritance

An introduction to inheritance

How inheritance works

How the Object class works

Basic skills for working with inheritance

How to create a superclass

How to create a subclass

How polymorphism works

The Product application

The console

The Product, Book, and Software classes

The ProductDB class

The ProductApp class

More skills for working with inheritance

How to cast objects

How to compare objects

How to work with the abstract and final keywords

How to work with the abstract keyword

How to work with the final keyword

Chapter 9 How to define and use interfaces

An introduction to interfaces

A simple interface

Interfaces compared to abstract classes

Basic skills for working with interfaces

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

New features for working with interfaces

How to work with default methods

How to work with static methods

The Product Viewer application

The console

The ProductReader interface

The ProductDB class

The ProductApp class

How to implement the Cloneable interface

A Product class that implements the Cloneable interface

A LineItem class that implements the Cloneable interface

Chapter 10 More object-oriented programming skills

How to work with packages

An introduction to packages

How to work with packages

How to work with libraries

How to work with modules

An introduction to the module system

How to create modules

How to use modules

How to use javadoc to document a package

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 work with enumerations

How to declare an enumeration

How to use an enumeration

How to enhance an enumeration

How to work with static imports

Section 3 More essential skills

Chapter 11 How to work with arrays

Basic skills for working with arrays

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 use the Arrays class

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 two-dimensional arrays

How to work with rectangular arrays

How to work with jagged arrays

Chapter 12 How to work with collections and generics

An introduction to collections

A comparison of arrays and collections

An overview of the Java collection framework

An introduction to generics

How to work with an array list

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 Invoice application

The console

The Invoice class

The InvoiceApp class

How to work with a linked list

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

How to work with maps

The HashMap and TreeMap classes

Code examples that work with maps

The Word Counter application

Chapter 13 How to work with strings

How to work with the String class

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 work with the StringBuilder class

How to create a StringBuilder object

How to append data to a string

How to modify strings

The Product Lister application

The user interface

The StringUtil class

The ProductListerApp class

Chapter 14 How to work with dates and times

An introduction to date/time APIs

The date/time API prior to Java 8

The date/time API for Java 8 and later

How to use the new date/time API

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

Chapter 15 How to work with file I/O

Introduction to directories and files

A package for working with directories and files

Code examples that work with directories and files

Introduction to file I/O

How files and streams work

A file I/O example

How to work with I/O exceptions

How to work with text files

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 Product Manager application

The console

The ProductManagerApp class

How to work with binary files

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

Chapter 16 How to work with exceptions

An introduction to exceptions

The exception hierarchy

How exceptions are propagated

How to catch exceptions

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 throw exceptions

How to use the throws clause

How to use the throw statement

How to work with custom exceptions

How to create a custom exception class

How to use exception chaining

An interface that uses custom exceptions

A class that uses custom exceptions

Section 4 GUI programming

Chapter 17 How to get started with JavaFX

An introduction to GUI programming

A GUI that displays ten controls

A summary of GUI APIs

The inheritance hierarchy for JavaFX nodes

How to create a GUI that accepts user input

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 create a GUI that handles events

How to work with buttons and boxes

How to handle action events

The Future Value application

The user interface

The code

How to validate user input

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

How to get started with FXML

An introduction to XML

How to code an FXML application

How to create the files for an FXML application

The Future Value application with FXML

The FXML file

The controller class

The application class

Chapter 18 How to get started with Swing

An introduction to GUI programming

A user interface with ten controls

A summary of GUI APIs

The inheritance hierarchy for Swing components

How to create a GUI that handles events

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

How to work with layout managers

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 Future Value application

The user interface

The code

How to validate Swing input data

How to display a dialog box

How to validate the data entered into a text field

The Validation class

How to validate multiple entries

Chapter 19 More Swing controls

More skills for working with controls

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 Payment application

The user interface

The code

Section 5 Database programming

Chapter 20 An introduction to databases with SQLite

How a relational database is organized

How a table is organized

How the columns in a table are defined

How tables are related

How to use SQL to work with a database

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

How to use SQLite Manager

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

Chapter 21 How to use JDBC to work with a database

An introduction to database drivers

Four types of JDBC database drivers

How to download a database driver

How to add a database driver to a project

How to work with a database

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

A class for working with databases

The DAO interface

The ProductDB class

Code that uses the ProductDB class

Section 6 Advanced skills

Chapter 22 How to work with lambda expressions and streams

How to work with lambda expressions

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 functional interfaces from the Java API

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 work with streams

How to filter a list

How to map a list

How to reduce a list

Chapter 23 How to work with threads

An introduction to threads

How threads work

Typical uses for threads

Classes and interfaces for working with threads

The life cycle of a thread

Two ways to create threads

Constructors and methods of the Thread class

How to extend the Thread class

How to implement the Runnable interface

How to synchronize threads

How to use synchronized methods

When to use synchronized methods

Reference Aids

Appendix A How to set up Windows for this book

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

Appendix B How to set up Mac OS X for this book

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

Index

Sample chapters

Chapter 1: An introduction to Java

If you’re completely new to Java, chapter 1 gets you started right by giving you some background on Java and showing you how to use an IDE to create, work with, compile, and run Java projects. By the end, you’ll be ready to start writing your own Java programs.

Chapter 2: How to write your first Java applications

To find out how quickly and easily you can learn Java from this book, download and read chapter 2. Whether you’re a programming novice or have years of programming experience, you’ll be writing complete Java programs by the end of this chapter.

Chapter 1 PDF (1.5Mb) Download Now

Chapter 2 PDF (875Kb) Download Now

Book applications, exercises, and an Eclipse tutorial

This download includes:

  • The source code for the applications presented in the book
  • The starting code for the exercises at the end of each chapter
  • The solutions to the exercises
  • A tutorial that shows how to use Eclipse with this book

All the code is provided in both NetBeans and Eclipse formats.

All book files: Exe file for Windows (19.1Mb) Download Now

All book files: Zip file for any system (19.0Mb) Download Now

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!

Yongjian Pan

Wednesday, 12 December 2018

I bought this book in October 2017 and have been using it to prepare for two of my Java classes and it has helped me a lot. Whenever I need explanation and clarification for more advanced concepts like object-oriented programming, polymorphism, and inheritance, I always referred to this book and even brought it with me to tutoring sessions. The most important thing I like about this book is that it is highly skilled-based, which is very important to beginners as other textbooks are more referenced-based and do not include complete programs. The learning process of computer programming is challenging, but this book does bridge the gap. I highly recommend Murach's programming books if you are trying to learn computer programming.

Angel Barranco

Wednesday, 23 August 2017

Great book for learning Java, Murach is worth every penny!

To leave a review, please log in to your account.     Log In Here

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!

Contact Murach Books

For orders and customer service:

1-800-221-5528

Weekdays, 8 to 4 Pacific Time

College Instructors

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.