Tom's Java Shack!


This page is devoted to displaying some of my experiments with Java(tm) applets. This isn't production-quality code, but you may find some of it interesting.


Cheesy money-making effort

I've put together a list of books I like here. If you click on one of the hyperlinked titles, it'll take you to amazon.com. If you buy the book from amazon, they send me a kickback. Cool, huh? Even if you don't buy anything, check these books out; they're all really good.
"Kim's Game"
This is a game that helps you test and improve your memory. It requires Swing support to work.
Reaction time tester
Click the button as it jumps around the page. Your average reaction time is displayed in the status bar.
Hypnotize yourself
Follow the pretty bouncing ball. You are getting sleepy... Your eyelids are getting heavy...
How to build COM objects from Java classes
If you feel like doing something naughty... Use the Microsoft SDK for Java to build COM objects from your Java classes.
How to use jUnit
A very brief intro to the jUnit test framework.
Groovy random color plotter
This started out as a boring old random number generator test tool, but now it's way groovy.
Invoking an executable from Java
How to invoke an executable file from Java and capture its exit code.
Native methods using JNI
A short example showing how to use JNI to invoke a C function.
A simple CORBA client
This example illustrates how to query your orb for a list of initially available services.
A simple mobile agent example

This brief example demonstrates the basic framework used to create mobile agents in Java. Uses RMI. If you're new to RMI, you might want to check out my brief RMI tutorial first, but the code is quite straightforward.


A write-up about printing in Java

This is a short piece on printing that I worked up in November 1997. It's been gathering dust for a few months; recently, I ran across it and decided that I might as well put it here. Enjoy!


A roundabout way to load an image

This applet shows how to use PixelGrabber and MemoryImageSource to disassemble and reassemble an image.


Physics-based modeling in Java

This program uses physics to simulate the motion of a bunch of balls connected by springs. The balls are initially assigned random positions, and the interactions of the spring forces and gravity eventually brings them to a state of equilibrium. Pretty cool. (This is a port of a program originally written for SGI GL by Dr. Jim Chen).


Printing text from a Java application

Here's a way to print text from a JDK 1.0.2 application.


A 1.1 event model example

Here's a brief example of how to use the 1.1 event model. This example also contains a "plain old" inner class and a couple of anonymous inner classes.


A Java web server

If you've ever wanted to tinker with a web server, but been put off by the size and complexity of the codebase, you might enjoy this. It's an ultra-tiny (under 200 lines) web server implementation in Java. It has extremely limited functionality (which I probably won't extend; there are enough full-featured web servers in the world already).


A port listener

Sockets got you down? Are you sending what you think you're sending? Use the PortListener program to find out.


A signed applet

Here's an example that shows how to sign applets using the "javakey" utility supplied with JDK 1.1.x.


A java.util.zip example

Here's a (perhaps over)simplified example of how to use the classes in java.util.zip to compress files.


An introspection example

Feeling nosy? Wondering what methods and variables a class has to offer? Well, look no further; here's an example that uses JDK 1.1's reflection and introspection to tell you what you want to know.


An easy RMI tutorial

There's no executable code here; rather, this is a step-by-step guide to creating your first RMI program. I've included source code that you can download, compile, and run on your machine (provided you're using JDK 1.1, of course).


Rubberbanding applet An applet that shows how to draw a rubberbanding rectangle while the user drags the mouse cursor. Source included as always. :-)


The right way to play a sound loop Here's an applet that plays a sound loop using the AudioClip class's loop() method.


A better method of inter-applet communication How to use a class with static data members to pass information between (or among) applets.


User Interface demo A somewhat involved demo that shows how to do a lot of UI-related stuff:
Click on the buttons or the menu choices to change the text in the canvas. Note: The frame will go away when you leave the page. :-)


Java Finger client Here's an implementation of a finger client in Java. It's an application, not an applet (because it wouldn't be very useful if it couldn't connect to arbitrary hosts). For those not familiar with "finger", it's a service that allows you to see information about a user on a remote machine. For instance, you could do: finger johnc@idsoftware.com to see what John Carmack, programming guru of Id Software, is up to.


Sound loop player This applet doesn't do anything visual; it reads as parameters the name of an .au file to play and the number of microseconds to delay between plays; it then plays the sound over and over again until you leave the page. It could be useful for ambience, but it's probably more annoying than useful. :-) Still, here it is.


Stack Example This is an applet that demonstrates the operation of the "stack" abstract data type, using a stack implementation that I wrote. It also illustrates how to declare and throw your own exceptions.
Random Rectangles Drawn from the "Brewing Java" tutorial, here's a multi-threaded app that draws random multi-colored rectangles.
Checkerboard Not a real checkerboard; just messing around with positioning of squares.
Scribble Drag the mouse to draw lines. This is a good program to write to get used to the basics of drawing and event handling.

The Source


Zoom Displays an image. By dragging the mouse up and down, you are able to zoom in and out. The name of the file to be used is passed as a parameter from the HTML.

The Source


IPC example A couple of applets that pass a value back and forth, incrementing it each time.

The Source


Bounce A bouncing sphere that changes colors at an annoyingly fast rate.

The Source


Time client and Server A client-server socket application. The client applet opens a connection back to a server on the host, and has a brief conversation in which it finds out the current time. Note: this applet relies on a server-side application that's not always running, so you may not get any response from it.

The source for the applet client

The source for the server application


Paddlegame A pong-like applet that I did to experiment with moving a couple of things around at once, one based on a thread and one reacting to user input. Endless hours of fun await you. :-)


JDBC Applet A sample applet that uses the JDBC-ODBC bridge to allow you to execute arbitrary SQL queries against any ODBC-registered data source available to you. It probably won't work properly from within your browser, but if you download the source and build it on your machine, you can run it from Appletviewer. Alternatively, you can build it as an application and run it with the command-line interpreter. Or you could skip running it at all and just take a look at the source code; I've tried to strip out the irrelevant and confusing stuff, leaving only the core functionality necessary to connect to databases, execute SQL, and retrieve and handle results.


Native method example Here's a quick-and-dirty example of how to make a native method call from a Java class.


An SQL client/server program using an applet as a front end and a socket connection for client/server communication.


Much more to follow! In the meantime, here are some cool links to other folks's java pages. (I finally decided to clean up the links section; I'll be adding more links shortly).

Java-related links

Dick Baldwin's Java site If he were to turn this site into a book, it'd run about 3000 pages, and it'd be really good. This is a great site.

RST's Java Security Hotlist A large number of links on anything and everything related to Java security.

The Javasoft homepage

The JavaBeans homepage

JavaSoft's API schedule and overview

The Java Developer's Connection Membership is free: join today.

The Java Lobby Devoted to promoting the interests of Java developers. Membership is also free. Join us! Join us!

The Java Series Some fine books on Java. Many of them are available online via links from this page.

Java data structures This is a pretty nifty tutorial on how to do some of the more common data structures (linked lists, stacks, binary trees) in Java.

Frag Island This is a pretty cool, no, really cool little applet. It's a first-person shooter (a la Doom, Quake, etc.) written entirely in Java.

Craig W. Reynolds' page
Some very cool stuff on computer modeling of behavior. In particular, check out Boids and Steering behavior for autonomous characters

Peter van der Linden's site
Useful things here include the comp.lang.java.programmer FAQ and the Linlyn class, which is a Java implementation of an FTP client that I've found quite handy.


You are the person to visit this page