Java

Java Has Me Outnumbered

I spent this afternoon working on several hundred mostly minor edits for the next printing of Sams Teach Yourself Java 2 in 21 Days, Fourth Edition. There was one major change: The javac compiler defaults to support for new features such as generics, autoboxing, and the data structure-crawling for loop. The default was originally to turn these off unless the -source 1.5 command-line option was employed. It's no longer necessary, though you can use -source 1.4 to turn off the new features and ... (read more)

Bush Clock Down for the Count

Four years ago today, I marked the inauguration by publishing a Java applet counting down the seconds "until the U.S. has an elected president again." I'm taking a beating in e-mail this morning from random strangers who remembered the clock and came back to taunt me. I'm not one to shy away from abuse (I'm a Democrat, after all), but there's a point I'd like to make to fuck@you.com and the other people who were kind enough to write. In 2 minutes and 13 seconds, the U.S. will have an elected ... (read more)

Thinking Outside the Box

Although I have been touting the new autoboxing and unboxing feature in Java 2 version 5, I didn't realize how far the language is willing to go with these automatic conversions. The following code doesn't work in version 4: public void setDeposit(Float deposit) {   if (deposit >= 0) {     this.deposit = deposit;   } } You can't use a comparison operator like ">" to compare a Float object and a float value -- an "incompatible types" error indicates ... (read more)Graham Hamilton reviews NetBeans 4.0, Sun's free integrated development environment for Java. The new version replaces the old project management system, which required folders and JAR files to be explicitly mounted before they could be employed in a class. I tried NetBeans out recently, finding the new version to be faster and simpler than its predecessor. However, I don't like IDEs that force users to learn a new interface with each version, so I'm sticking with the source code editor ... (read more)

Get Up to Speed with Velocity

Trygve Isaacson is dumping some of his own Java code in favor of Apache Velocity, a terrific open source template publishing engine. In the process, he found a solution to a thorny configuration problem that prevented his Web server from finding templates. I wrote an introduction to Velocity for the December 2002 Linux Magazine. Using its own scripting language, Velocity Template Language, the class library prevents template creators from making the biggest mistake of JavaServer Pages -- mixing ... (read more)IBM has donated Cloudscape, an embedded relational Java database that has been in active development since 1996, to the Apache project, where it will be called Apache Derby.There's a Cloudscape tutorial site on IBM DeveloperWorks and an Apache Incubator site where it can be downloaded. ... (read more)

Java 2 in 24 Hours Panned

Just read an old review by Pan Pantziarka shredding Sams Teach Yourself Java 2 in 24 Hours, my beginner's Java book last revised in 2002.By the end of the book, assuming you haven't been stunned into a coma by the author's humor (yep, it's a US thang), you'll have a very superficial view of Java programming. What you won't have is the knowledge or the insight to produce anything useful.Mommy.This book, which has done well with new-to-Java novices, will occasionally receive a total ass-kicking ... (read more)

Java applet takes forever to run

One of my favorite works of art was executed as a Java applet. I bought Every Icon by John Simon Jr. in May 2000 and have been meaning to put it on my Web site ever since. The display of the work takes several hundred trillion years from start to finish, so I don't feel so bad about taking almost four years to share it on Workbench. ... (read more)

Java 1.5's quirky new static import

David Flanagan has been experimenting with the new static import feature in Java 2 version 1.5, which provides a shorthand way to refer to class variables: import static java.lang.System.out; class SalutonMondo { public static void main(String[] args) { out.println("Saluton Mondo!"); } } That seems simple enough, but as Flanagan demonstrates, the static import keyword does some things you might not expect. ... (read more)

Peer into the future with JXTA

My November 2003 Java Matters column for Linux Magazine is now available online. It covers JXTA, a set of XML protocols for peer-to-peer network programming created as an open source project by Bill Joy and Mike Clary at Sun Microsystems. JXTA's an extremely ambitious project with a steep learning curve. A quote from the column: The formulation of networks on the fly, with or without a central server, through firewalls and with authentication and encryption, atop the Internet and other networks ... (read more)