| Books & Tools | Techniques | |
|
Comprehensive coverage of Ruby 1.8 and 1.9
"The New Most Important Ruby Book" JudeJude 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 NutshellThe 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 NutshellThe 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 NotebookAmazon 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 JavaI 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, 2005New <canvas> tag in Firefox and SafariI'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, 2005URL vs URI class for URL-to-File conversionMy 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 40As promised below, Mustang build 40 incorporates JSR 223, Scripting for the Java Platform, and includes the Rhino JavaScript interpreter. June 10, 2005Java 6.0 'Mustang' DetailsHere 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 June 03, 2005Jude 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:
|
Advertising
About
Store
Search
Archives
April 2008
March 2008 February 2008 January 2008 November 2007 October 2007 September 2007 August 2007 July 2007 June 2007 May 2007 April 2007 March 2007 February 2007 January 2007 December 2006 November 2006 October 2006 September 2006 August 2006 July 2006 June 2006 May 2006 April 2006 March 2006 January 2006 December 2005 November 2005 October 2005 September 2005 August 2005 July 2005 June 2005 April 2005 March 2005 February 2005 December 2004 October 2004 September 2004 July 2004 June 2004 May 2004 April 2004 March 2004 February 2004 January 2004 Syndicate
|