Wednesday, February 27. 2008
Here is the easiest process I have found for setting up Ruby and PostgreSQL on OS X Leopard at this time.
I recommend PostgreSQL for Mac instead of fink as it is more actively maintained and easier to install. Note that when downloading, use the alternate download not the Sourceforge links, as the Sourceforge download is not current and has issues. This installer places the PostgreSQL CLI commands in /Library/PostgreSQL8/bin/ and will auto-start PostgreSQL on system startup. It includes some graphical tools, but I recommend ignoring them and and installing pgAdmin III if you want an administration GUI (I usually just use the CLI tools).
Ruby has a couple PostgreSQL gems, I recommend ruby-pg which appears to be the only one actively maintained. The easiest way to get it installed is to download the latest .gem, then run the following command to install it in the directory where you saved it (replace the version number as necessary):
PATH=$PATH:/Library/PostgreSQL/bin/ gem install pg-0.7.9.2008.02.05.gem
Don't waste your time trying to find documentation for this gem online, point your browser at the documentation on your local machine, which for this version was at:
file:///Library/Ruby/Gems/1.8/doc/pg-0.7.9.2008.02.05/rdoc/index.html
Thursday, December 20. 2007
When storing preferences for applications on Java, there is a built in Preferences API. If you need full control of preference storage or need to change it from applications external to Java or manually, one of the options I discussed last year may be better (if you need an XML file in a specific location for example), but if you just need simple cross-platform preference storage, the built in option is ideal.
Usage Summary
import java.util.prefs.Preferences;
Preferences prefs = Preferences.userNodeForPackage( getClass() );
prefs.get("keyName", "default value");
prefs.put("keyName", "new value");
The JavaDoc for it is quite confusing, so try this tutorial on java.util.prefs.Preferences instead.
Thursday, December 6. 2007
Netbeans 6 has been released. I have been using it since beta 1 and have found it an invaluable improvement over the old version. The editor and layout is improved, and subversion support is now built in. The major change in this release is the language support; Ruby support is now available, and there is a PHP plugin. I'll report as I try these other plugins over the next few weeks.
Tuesday, October 30. 2007
When building Swing applications customized for OS X, note that for more complex applications with multiple JFrames, a JFrame containing a JMenuBar must be initialized first. If a JFrame with no JMenuBar is created first, neither the custom application name nor the menus will work correctly.
Continue reading "OS X: JFrame with JMenuBar Must Be First"
Thursday, October 25. 2007
Wish you could have multiple keys in your Map class? Want to add constraints easily to your collections to ensure the data is as expected? Both of these and much more are available in the Google Collections Library. Obviously these can be coded yourself; but this library offers a more elegant and better tested way to build some of these useful data structures.
Wednesday, October 10. 2007
When receiving the error java.net.MalformedURLException: unknown protocol: dummy , check everything included in all libraries and classpath elements for old or conflicting versions of Xerces and Gnu Jaxp. Dummy is a basic, built-in protocol, so if it is not locatable there is a library conflict.
Thursday, September 20. 2007
Getting blank pages from your java.awt.print.Printable implementation? Check for null pointer exceptions. Uncaught null pointer exceptions generated by your implementation of print() method are silently thrown away. I have noticed this behavior on Java build 1.5.0_07-164 on OS X.
Thursday, August 9. 2007
I was getting an error when trying to run ant junit on a project from the command line for a Netbeans 5.5 project. There are many hard to humanly parse solutions out there via Google. The solution that worked for me:
Continue reading "Netbeans 5.5 'ant junit' Not Working from Command Line"
Thursday, May 31. 2007
When using the subversion client built into Netbeans 5.5 on OS X with the svn+ssh protocol, it ignores the username entered and always uses the logged in user's username. This occurs both when entering a username in the field for it and when using a url like svn+ssh://username@server.com/svnrepo . Fortunately if you encounter this problem, there is a workaround:
svn+ssh://username@username@server.com/svnrepo
Netbeans only strips the first username@, leaving the second one in place. Everything then works as the correct URL gets properly embedded in the right places.
Continue reading "Netbeans svn+ssh Username Glitch"
Monday, May 21. 2007
Looking for an easy way to launch a browser window from your swing application? The easiest solutions I found without using a library involved JNLP; not a good answer for my cross platform Swing applications. There are quite a few solutions, but I like Browser Launcher 2. Only 92kb, it seems rather good at finding the user selected system default browser, and its ease of use is hard to deny:
BrowserLauncher().openURLinBrowser("http://example.com");
Wednesday, May 9. 2007
I have been using the PDFBox library when working with PDF files, most commonly to extract the text for lucene indexing and generating thumbnails conveniently in Java. Recently I have started to see this error when generating thumbnails, which come out as properly sized plain white pages:
java.io.IOException: Unknown stream filter:COSName{JBIG2Decode}
Some of the latest PDFs, in this case from a new Xerox copier (which scans into PDF format), generates black and white images in PDFs using the JBIG2 format. Java has no built-in support for JBIG2 yet, and building a handler for this image type into the PDFBox library isn't an option for the development team at this time.
Continue reading "Java Lacks JBIG2 Image Support"
Thursday, March 15. 2007
After the Harrisburg Java User's Group meeting tonight, two items in particular came up in the post-presentation discussions which I am mentioning here mainly for my own reference, but will likely be valuable to anyone reading this doing Java programming.
The Java 2 Platform, Standard Edition 5.0 Trouble-Shooting and Diagnostic Guide is a comprehensive guide to the tools that are available as part of JDK5 to analyze Java programs. Interestingly many of these tools do not exist on Windows, but they are in OS X as well as the mentioned Linux and Solaris.
Available as part of the stock Java 5 standard libraries, the JSR 166 Concurrency Utilities allow the building of many common concurrency models without the complication of doing such programming from scratch. Concurrent programming is becoming important as more cores become increasingly dominant in modern computers.
Thursday, March 1. 2007
A date chooser is a frequent element needed when building Swing applications. I have been using JCalendar widgets for my needs. They have an excellent selection of widgets to fit most needs, including separate month and year choosers for cases where you don't need whole dates (like credit card months and years) licensed under the LGPL open source license.
These work well with Netbeans. Make a JCalendar library using the Library Manager , then add the library to your Swing widgets palette. Use Tools , Palette Manager , Swing/AWT Components , then click on Add from Library to allow drag and drop of these widgets in Matisse.
Wednesday, January 17. 2007
Although I code most of my more complicated projects in Java, I still use PHP for simple projects and have many old applications still using it. When doing database work in PHP I use Pear DB to avoid built-in api changes, and because it is very similar to Perl DBI as well as many other database abstraction layers which I am already familiar with.
Recently Pear DB has been deprecated in favor of Pear MDB2. DB will continue to be supported with security updates, but new development has moved to MDB2.
Tuesday, December 12. 2006
When programming Java servlets and building display code, the context path of the application is often required. From the JSTL ${pageContext.request.contextPath} it might appear that it is a simple matter of using pageContext.getRequest().getContextPath() . There is a bit of a gotcha here though, as pageContext.getRequest() by default returns an object of type ServletRequest and not HttpServletRequest, which is what you need. Casting to the correct type fixes the issue:
String myContextPath = ((HttpServletRequest)pageContext.getRequest()).getContextPath();
|