Books & Tools Techniques

Comprehensive coverage of Ruby 1.8 and 1.9

"The New Most Important Ruby Book"
Peter Cooper,
rubyinside.com

Completely updated for Ajax and Web 2.0

"A must-have reference"
Brendan Eich,
creator of JavaScript

Jude

Jude is my Java documentation browser. It combines Sun's definitive javadocs with the easy-to-use format of Java in a Nutshell, and tops it off with easy keyboard-based navigation and full-text searching.

Jude is available for free evaluation.

See the user's guide for more info

Java in a Nutshell

The 5th edition is now out, with complete coverage of Java 5.0!

It includes a fast-paced tutorial on the language, and a compact quick-reference for the core Java API.

Java Examples in a Nutshell

The 3rd edition, updated for Java 1.4

This edition has all-new coverage of the NIO and JavaSound APIs, completely rewritten Servlets and XML chapters, and coverage of new Java 1.4 features (assertions, logging, preferences, SSL, etc.) added througout. A great book for those who like to learn by example. 193 working examples: 21,900 lines of carefully commented code to learn from.

Java 1.5 Tiger: A Developer's Notebook

Amazon incorrectly credits me as the main author on this book. I'm actually the second author: really more of a consultant. This is a good book about all the language changes in the latest version of Java.

Effective Java

I didn't write this excellent book, but I wish I had.

Author Josh Bloch is probably best known for the collections classes in the java.util package. His experience and wisdom are apparent in this book. I learned from it and recommend it highly.

June 17, 2005

New <canvas> tag in Firefox and Safari

I've been reading about the new <canvas> tag supported by the latest Safari and by the latest alpha release (codenamed Deer Park) of Firefox.

It is very cool: it exposes a sophisticated 2D drawing API (comparable to Java2D, but without text support) to client-side JavaScript.

My demo is here. It uses the canvas tag to draw a quadratic bezier curve and allows you to drag the control point around to change the curve.

It doesn't work for me in Safari 1.3, but it does work in Deer Park (a.k.a.Firefox 1.1) Alpha1

Almost reason enough to download a new browser!

Update: In comments, Berndt Jung links to a version of my demo that does work in Safari. He takes the text out from inside the <canvas*gt; tags, since Safari always renders it. But mostly, he figured out that due to a bug (being fixed) , the quadraticCurveTo() method is not actually bound.. The workaround is to use quadraticCurveToPoint() instead, on Safari only.

June 13, 2005

URL vs URI class for URL-to-File conversion

My Jude 1.00 release shipped with the following method in it to determine its own installation directory:

    static File getInstallationDirectory() {
	java.net.URL url = Main.class.getResource("Main.class");
	String protocol = url.getProtocol();
	File f = null;
	if (protocol.equals("file")) {
	    // Go up twice for jude/Main.class
	    f = new File(url.getPath()).getParentFile().getParentFile();
	}
	else if (protocol.equals("jar")) {
	    String s = url.toString();
	    int pos = s.lastIndexOf('!'); // ! marks beginning of jar entry
	    s = s.substring(9, pos); // 9 is the length of "jar:file:"
	    f = new File(s).getParentFile();
	}
	
	return f;
    }

It uses Class.getResource() to get a URL for one of its own class files. Then it parses this URL (which may be a file: or jar: URL) to determine the installation directory. I think its a clever thing to do. But ithere is a bug (which has been fixed in Jude 1.01, which I've just releases). Can you spot it? (The answer is below)

I got a bug report this morning from someone who had tried to install Jude in c:\Program Files on a Windows system. Jude wouldn't start up from this directory because it couln't find its license file. It was looking for a directory named "Program%20Files". Spaces aren't legal characters in URLs, so the java.net.URL class uses the correct %20 escape sequence. Unfortunately, the URL class isn't smart enough to unescape those characters.

Fortunately the java.net.URI class (added in Java 1.4) is smart enough. This code fixes the bug:

    static File getInstallationDirectory() {
	java.net.URL url = Main.class.getResource("Main.class");
	java.net.URI uri = java.net.URI.create(url.toString());
	String scheme = uri.getScheme();
	File f = null;
	if (scheme.equals("file")) {
	    // Go up twice for jude/Main.class
	    f = new File(uri.getPath()).getParentFile().getParentFile();
	}
	else if (scheme.equals("jar")) {
	    String s = uri.getSchemeSpecificPart();
	    int pos = s.lastIndexOf('!'); // ! marks beginning of jar entry
	    s = s.substring(5, pos); // 5 is the length of "file:"
	    f = new File(s).getParentFile();
	}
	
	return f;
    }

The moral of this story, I suppose, is to use the URL class when you actually want to retreive the resource referred to by the URL. But if you just want to parse or manipulate the URL, then use the URI class.

Feel free to adapt the getInstallationDirectory() method above for your own use if you like it (Note that it is specific to Jude in a couple of places). And if you've got another way to find the install dir for an application, please share in the comments.

JavaScript in Mustang build 40

As promised below, Mustang build 40 incorporates JSR 223, Scripting for the Java Platform, and includes the Rhino JavaScript interpreter.

June 10, 2005

Java 6.0 'Mustang' Details

Here is a nice summary of new features in the core platform (i.e. not desktop features) for Java 6.0

I came upon this almost by accident (thanks, google!). It is dated 6 days from now, so I think it must be pretty new.

The detail that is most interesting to me is that the JSR-233 JSR-223 (Scripting for the Java Platform) implementation will be included in build 40 (in a week or two, I think). And, it will include the Rhino JavaScript engine! So every Java 6.0 application will automatically have an embedded JavaScript interpreter. (And readers of Java in a Nutshell will go out and buy JavaScript: The Definitive Guide! :-)

June 03, 2005

Jude 1.00 Released!

After years and years of development, I've finally released version 1.00 of Jude. Jude is an alternative to javadoc. It displays definitive API documentation from documentation comments in Java source code. But its output is easier to browse than javadoc, it is better looking than javadoc. And it is searchable. And customizable. Want to see methods listed alphabetically? Jude does that. Want them grouped functionally instead? A single keystroke will toggle between these two views!

There are too many features to describe here. If you haven't tried Jude yet (or recently), please give it a spin:

  • Read more about Jude (and view screenshots) on the home page, and in the User's Guide and Administrator's Guide.
  • Download the Jude 1.00 release here.
  • Get an evaluation license to make the release work here
  • And, if you like it, you can buy a license (for less than you'd spend on a good Java reference book) here.

Advertising
About
Store
Search
Google
Web this site
Archives
Syndicate

Powered by
Movable Type