Recently I ran into a programming situation where I needed to select a node in a Java JTree from my code. As opposed to the usual situation of responding to a user's click on a JTree node, I needed to set the active JTree node based on something that was happening in another area of the application.
Alvin Alexander | Java, Scala, Unix, Perl, Mac OS X
Wow, if only 10% of the comments on this page are accurate, there is a huge amount of trouble and turmoil at Microsoft on the Vista project. This blog posting makes me feel even better that I just made the switch to the Mac world.
This post is terrific:
What's the difference between OS X and Vista?
Microsoft employees are excited about OS X...
If you’ve never read the book Use Case Driven Object Modeling with UML by Doug Rosenberg and Kendall Scott, you’re missing one of the most simple and important Model-View-Controller (MVC) diagrams in the software business.
In their discussion of Robustness Diagrams they introduce a figure called “Robustness Diagram Rules” that succintly tells you how to implement an MVC design in your code. In one figure they tell you:
Java jar file reading FAQ: Can you show me how a Java application can read a file from own of its own Jar files?
Here's an example of some Java code I'm using to read a file (a text file) from a Java Jar file. This is useful any time you pack files and other resources into Jar files to distribute your Java application.
Java - read Jar file example #1
The source code to read a file from a Java Jar file uses the getClass and getResourceAsStream methods:
Java HTTPS client FAQ: Can you share some source code for a Java HTTPS client application?
Sure, here's the source code for an example Java HTTPS client program I just used to download the contents of an HTTPS (SSL) URL. I actually found some of this in a newsgroup a while ago, but I can't find the source today to give them credit, so my apologies for that.
Here is a Ruby mail program that I use to search my IMAP mailbox with combinations of search criteria. It is a mixture of several different Ruby-based approaches I found on the Internet for searching email systems.
Note that you don't need all the comments at the front as I've shown. It's just that I can't remember all the crazy flags that can be used, and at this time I'm not going to take the time to write a better mail system interface, although IMHO a better interface is surely needed.
I don't work in the DOS (Windows command (
CMD.EXE)) world too much these days, but I needed to today. The basic problem was that I needed to build an environment variable dynamically. In this case I was trying to build a variable named
CLASSPATH from a collection of Java JAR files in a sibling directory named
LIB. This variable had to be built correctly for my Java application to work properly.
SVN directory FAQ: How do I move a directory with subversion (svn)?
svn directory move example
Moving a directory (or file) with Subversion (SVN) is very easy, you just need to use the "svn move" command. Let's try a simple example.
Suppose you have a directory named
foo, and you want to rename it to
bar. The svn move command to issue is:
CVS login FAQ: How do I login to a CVS server using SSH?
cvs login - a Windows example
Here's how I do a "cvs login" to our CVS server using SSH, on a Windows PC:
set CVSROOT=:ssh:firstname.lastname@example.org:/home/cvs/ cvs login
Note that the only real different thing here is that you specify the ssh protocol for communicating with the server.
MySQL database FAQ: Can you share an example MySQL database schema (i.e., a MySQL database create script).
For what I do I often need a sample database. For my current writing I decided to use the "coffeebreak" database defined in Sun's JDBC tutorial. If it saves you any time in your work, here are the commands. I've only tested these with MySQL, but they should work with most other databases.
Before worrying about the schema, here are three steps that you'll want to do first:
MySQL login FAQ: How do I log into a MySQL database?
Assuming you have the root password, this MySQL command from your Unix/Linux command line will work:
mysql -u root -p
After issuing that MySQL login command you will be prompted for the root user password. Just enter that root password, and you should be in. After you login, your console should look like this (using MySQL version 5):
After you've made a few changes in your local SVN sandbox it can be helpful to check the SVN status to see what you've changed, or at least see what SVN thinks you've changed. To do this, just issue the
svn status command to see the changes, like this:
In my case this "svn status" command returned the following information:
A build.alspc A antAlsPC.bat M build.xml
Here's a quick example of an svn commit command in what I think is a very typical scenario. Assuming that I just made a few changes to some files in a directory, to commit those changes back to the repository, I just issue an "svn commit" command like this, incuding a nice svn commit message:
svn commit --message "Enabling build processes to support multiple platforms"
(Don't forget -- a good SVN commit message can really help you out later. I find it helps to say both what I did, and why I did it.)
Subversion/SVN checkout FAQ: How do I checkout a project with Subversion?
svn checkout command example
I currently work at a consulting company, so we organize our projects first by client, and then by project. So, assuming I have a customer named ACME, and a project named Project1, this svn checkout command (
svn co) worked for me:
Java Log4J FAQ: Can you share a simple Log4J example?
I don't have a lot of time today to get into all the Log4J properties and configuration options you can use, but I wanted to share at least one Java Log4J example here, so here goes.
A Log4J example Java class
The following Java Log4J example class is a simple example that initializes, and then uses, the Log4J logging library for Java applications. As you can see the configuration is pretty simple.
Before discussing my reasons for making the switch, let me first state that I am not currently an iPod or iTunes user. I may get to those things eventually, but for now those things are non factors, and what I'm most interested in is developing new software for customers, and designing new software systems.
To put the JGoodies FormLayout into debug mode, when you're creating a builder, instead of doing this:
PanelBuilder builder = new PanelBuilder(layout);
add in a FormDebugPanel, like this:
// debug mode PanelBuilder builder = new PanelBuilder(layout, new FormDebugPanel());
This enables what I think is a terrific debug feature, showing red lines around whatever grid structure you've created. (Sorry I don't have an image out here for this tutorial, but it really is a terrific GUI debugging feature.)
After reading Ben Galbraith's post titled "Give Me My Commodity Text Widget Features, Please", I decided to create my own auto-complete text widget for Java.
There is a disease I see so often in the software development industry that I've decided to give it a name. I call it "Kirk/Scotty Syndrome". This disease is related to the concept of "software rot" and "spaghetti code" inflicted by the management team. You'll know this disease when you hear it, because it will sound a lot like the following conversation, taken from most Star Trek episodes: