Earlier this year, I discovered Wicked Cool Java. Written by Brian D. Eubanks and published by No Starch Press in November 2005, this interesting and helpful book shows Java developers how to get creative with Java by presenting 101 exciting and cool code bits, open source projects, and project ideas. In this article, I present my review of Wicked Cool Java and interview Brian D. Eubanks.

Wicked Cool Java

Wicked Cool Java is not a book for those new to Java. In the introduction, Brian states that he "didn't want to write another 'how-to-program-in-Java' book." Instead, Brian makes it clear that he wanted to write "a book just for the joy of discovering interesting things to do in Java without reinventing the wheel." This book is for those who possess a basic to intermediate level of Java knowledge and are looking for ways to enhance their code.

Wicked Cool Java is organized into eight chapters and an extensive glossary. The first chapter focuses on the Java language and core API. You look at Java 5's new for loop, enums, generics, and variable-arguments language features; you also play with assertions, System.nanoTime(), sub-millisecond thread sleep, and anonymous classes. I especially appreciated the section on equal rights: operator == and the equals() method are not equivalent. Brian's clear discussion of this common pitfall to even experienced Java developers is one of this chapter's jewels. Did you know that the garbage collector thread can remove an interned String value?

Chapter 2 focuses on string processing. This chapter first introduces regular expressions for performing text search, string splitting, text substitution, and more. The Scanner class is next introduced to overcome a limitation with the Matcher class (I won't tell you what that limitation is ... read the book!) Moving on, the topic of generating random text for testing purposes is presented. You next discover Array's deepToString() method for viewing the contents of nested arrays in a meaningful way—a method I was previously unaware of.

The next topic begins one of this book's major themes: introducing Java developers to open source projects that save them from "reinventing the wheel." You discover two classes in Apache's Jakarta Commons Codec project for converting between binary data and hexadecimal or Base64, which is part of the Multipurpose Internet Mail Extensions (commonly referred to as MIME) for representing binary data in a human-readable format. Chapter 2 concludes with a discussion on using MessageFormat and System.out.format() to format data.

At some point in your Java career, you'll need to process well-formed HTML and XML documents. After providing a quick XML refresher, Chapter 3 shows you how to parse XML documents via Java's built-in SAX (Simple API for XML) parser and the open source DOM4J Document Object Model (DOM) parser. Did you know that DOM4J supports XPath? That expression language lets you conveniently traverse a DOM4J tree, and this book shows you how to do just that. You next learn about JavaCC, the open source parser generator for creating parsers based on your own grammars, and look at converting these grammars into XML. I really enjoyed the chapter's discussions on using Java Database Connectivity's WebRowSet interface and its implementation class for converting database query ResultSets to XML, screen-scraping data from HTML pages, and working with the open source Lucene API to add sophisticated search logic to applications.

Chapter 3 is an exciting chapter to read, but Chapter 4's discussion on crawling the Semantic Web is just awesome. The Semantic Web is a step up from the current Web in that the Semantic Web links concepts to concepts, not hypertext documents to other hypertext documents, via keywords. After introducing you to the Semantic Web, the Resource Description Framework (RDF) for specifying exactly how to relate entities to each other, and RDF Site Summary (RSS) feeds for appropriately tagging documents and syndicating their content, this chapter introduces the open source projects N3 and Jena. N3 is a notation for representing relationships and Jena is an API for working with RDF graphs and converting them to N3 and other kinds of documents. See Resources for an excerpt from Chapter 3.

Chapter 4 also introduces you to Lojban, an artificial spoken and written language based on predicate logic, and shows you how it fits with RDF; introduces Brian's Jorne project that defines standards for combining Lojban with the Semantic Web; and introduces Informa for publishing, aggregating, polling, and filtering RSS feeds.

In its early years, Java acquired the reputation of having no good mathematics and science libraries. This is no longer the case, as Chapter 5 proves. In this chapter, you learn about:

  • Functors—in the context of the Generic Algorithms for Java (JGA) API—and their usefulness
  • Colt's BitVector and BitMatrix classes for modeling logic functions and creating truth tables (respectively)
  • JScience for scientific and mathematics processing
  • JGraphT for modeling graphs
  • Joone for building neural networks
  • JGAP for working with genetic algorithms
  • Jade for building intelligent agents
  • JWordNet for discovering word meanings and relationships among words

Chapter 6 is one of my favorite chapters. This chapter focuses on graphics and data visualization. The chapter begins by looking at SwiXML, an open source Swing layout engine. With this tool, you define your GUI layout as an XML document, and the tool automatically creates the GUI from that document. You no longer need to mess with creating GUI components and setting their properties.

This chapter next introduces you to Batik, an open source tool for rendering the contents of a Graphics2D-based canvas to a scalable vector graphics (SVG) XML file. You can also use Batik to view the contents of SVG XML files. In addition, you learn how to convert JGraphT models to JGraph models; JGraph emphasizes graph visualization, which is not the case with JGraphT.

Do you need to create a pie chart? If so, you'll appreciate Chapter 6's JFreeChart example. The chapter also shows you how to create reports with JasperReports and how to build 2D structured graphics with Piccolo. Although coverage of open source tools dominates Chapter 6, you also examine two graphics and data visualization techniques built into the core Java API—the affine transform is one example.

Chapter 7, another favorite chapter, explores multimedia and synchronization. You learn how to use:

  • JFugue to easily introduce music based on MIDI (Musical Instrument Digital Interface) into your applications
  • JMusic to create your own MIDI instruments
  • FreeTTS to make your programs talk back to you
  • Javolution to minimize execution delays introduced by the garbage collector thread (which is important in real-time scenarios)
  • Java's own CyclicBarrier class to force a specific number of threads to wait at a common barrier point until the final thread arrives at that point—then all threads can proceed

The final chapter examines miscellaneous open source projects and core Java features, and presents ideas for creating your own projects and integrating code from previous chapters into these projects. You will enjoy the discussion of Lego Mindstorms and the LEJOS open source firmware for controlling the RCX computer for your robots, playing with the Abstract Window Toolkit's Robot class for automating program execution, and working with the open source JCalendar and JDateChooser classes for conveniently selecting dates from a calendar. And, if you are looking for your own open source project to create, you will find some intriguing ideas, including a robotic brain and an annotation management tool.

In less than 250 pages, Wicked Cool Java shares a wealth of useful information about interesting Java APIs and available open source projects. You will think up all kinds of ideas (such as using FreeTTS to have your software explain its uses and benefits to your boss or customers) as you read this book. And, when you finish reading, you will definitely want to check out the book's companion Website (see Resources), where you can find links to the open source projects, errata, the complete code to the various code bits peppered throughout the book, and more.

An interview with Brian D. Eubanks

Brian D. Eubanks is a consultant, speaker, trainer, and author who specializes in Internet technologies. Brian is also the founder of Eu Technologies, Inc. I recently interviewed Brian about his Wicked Cool Java book.

Jeff Friesen: What motivated you to write Wicked Cool Java, and what is this book about?

Brian Eubanks: I've always enjoyed learning and experimenting with new technologies, and discussing interesting ideas with other people. I think Java is a cool language, and there is so much that you can do using the many open source projects that are available. Some Java programmers are only familiar with the core API, and I wanted to show that there is much more out there. The book attempts to answer the question, "What can I do in Java that is fun or interesting or useful?"

JF: What is your favorite part of Wicked Cool Java? Is there anything in the book that you would like to have done differently?

BE: I particularly enjoyed working with the scientific and mathematical APIs. There are so many of them, and I had a difficult time deciding which ones to highlight in the book. In some cases, I got heavily into learning an API and then discovered a better one to do the same thing. That was frustrating. I also got lost in the research, because it was way too much fun discovering new projects.

I would definitely have put the book's Website together a little earlier (the Website was not complete until a couple of weeks after the book was released; this proved frustrating for those readers who tried to access the Website's links). I would also have completed an advanced cell matrix implementation before the book was out. I'm currently working on the design for a cell matrix simulator that's multidimensional, completely configurable, and networked, but due to time constraints, it is moving very slowly. I'll eventually make it an open source project.

JF: Are there any core API features, or are there any open source projects that you would have liked to discuss in this book, but could not do so for space or other reasons?

BE: This is the kind of book that an author can never truly finish, because it is so open-ended. I wanted to add some J2EE and design patterns, but there are already so many J2EE books on the market, and it would have taken lots of additional space.

JF: What open source Java projects have you created? Do you have any plans to introduce an open source Java project?

BE: I created the Jorne project for working with Lojban and RDF, which I hope will gain some more interest from developers. I also plan to start a project for cell matrix-related Java code.

JF: Your first chapter focuses mainly on Java 5 language features. With Java 6 soon to replace Java 5, do you see any interesting new language or core API features that you might want to incorporate in the first chapter of a sequel to this book?

BE: The JAXB [Java Architecture for XML Binding], Web services, and AWT/Swing enhancements are good possibilities.

JF: In your discussion of JMusic, you talk about your family's electronic music synthesizer kit. You also reveal considerable knowledge of sound generation. To satisfy my curiosity, are you a musician?

BE: Yes, while I was growing up, I studied clarinet and saxophone. I also dabble a little in composition and singing.

JF: Have you written any other books; do you have any other book projects under development; any plans to write future books?

BE: I have not written any other books, and don't currently have any books in development. However, I do plan to write again.

I want to thank Brian for his willingness to respond to my questions. I really enjoyed his book and I hope that he will write a sequel. If you do not have a copy of Wicked Cool Java and are looking for some cool things to do with Java, you owe it to yourself to get a copy.

Jeff Friesen is a freelance software developer and educator specializing in C, C++, and Java technology.

Learn more about this topic

Jeff Friesen teaches Java technology (including Android) to everyone.

Follow