Note: You must have a Java Runtime Environment installed to run these programs. You can install one (if necessary) by visiting Sun's installer page.

Yay! I passed the Sun Certified Java Programmer test! So I can now put this logo here:

java certified

I wanted to learn Java and Swing, so I wrote some little Java games. I'm sure others have done them before me, but I don't care. I did it just as a learning aid.

Most of these require a Java runtime environment equipped with the Swing libraries. They were developed with the version 1.3.1 JDK, but probably will work with earlier JREs if you add swing libraries (which I believe can be downloaded separately from Sun).

I'm releasing them under the GPL, so you can go look at the source code if you like. If you do, I'd appreciate any suggestions you might have about how I can write better Java code. I'm sure I made every mistake a newbie can make. That, and the code wasn't architected in advance, so I'm sure the class hierarchy is a bit... haphazard.

The GPL requires you to give away the source if you distribute it. To make this easy, I stuffed a copy of the source in the actual JAR file, so as long as you don't modify the JAR file, you can give it away to anyone you like with no further obligation.

Oh, I have a special trick for invoking platform specific code without contaminating your program and forcing you to release different versions. Read about it here if you're familiar with Java programming.

I came across another little trick for loading JDBC drivers dynamicaly.

JOthello

This is the classic Othello (aka Reversi and many other) game. The game pieces are white on one side and black on the other. When it's your turn, you add a new piece to the board of your color, flipping over any of your opponent's pieces that are between the new piece and another of yours (in a straight line with no gaps). You may not place a piece down where no existing pieces would be flipped. If you cannot place a piece at all, then your turn is skipped. The game ends when neither player can play. The player with the most pieces flipped his direction wins.

Note I'm particularly interested to hear from anyone running Mac OS X. I wrote some special code to make it work like a native Mac application when it's run on a mac. I'd like to know if that code works or not. You should notice that:

  1. The menu bar is at the top of the screen rather than in the window
  2. The application menu is named "JOthello", like it should be
  3. That the "About JOthello...", Preferences and Quit items in the JOthello menu work
  4. and that the Game/Quit and Help/About menu items do not show up

Game play

You are white, the computer is black. White goes first.

If you go into the preferences, you'll see two options: Difficulty and Algorithm. The Difficulty slider sets how "hard" the computer thinks (or put another way, how far it looks ahead).

The algorithm selector selects how the computer looks at the board. It's sort of in the form of multiple personalities:

To do

Download it here

Now you can even run it as an Applet!


JPuzzle

Here's my second effort. It's one of those little sliding tile puzzles, except that it uses pictures instead of numbers. It has some built in, and if you want you can load your own pictures.

Download it here


MacXM

My third effort isn't really a game, and it isn't in Swing. It's MacXM, which is a Macintosh UI for the XMPCR. I am writing it in Java/Cocoa (and a tiny bit of C in the form of a JNI helper method). I have another helpful hint, this time about sharing file descriptors between Java and native methods.

You can find MacXM at its home page.


JXM

MacXM was nice, but it reached a rather limited audience (people with both a mac and an XMPCR). I've decided to get going on the JXM project, which will be a SWING UI for the XMPCR. Go check it out.