Various articles on programming - mostly Java example code

Written by Sean R. Owens (sean at guild dot net). Share and enjoy.
For other fine writings on Java and other subjects, check out notablog at

You will find here a selection of simple, clear examples of how to do various things in Java. I don't claim to be an expert in Java, I'm just trying to provide some simple examples. Take it as you will.

These examples assumes basic familiarity with Java, especially with how to compile and run programs. If you need help compiling and running these, don't ask me. Go somewhere else.

I've also collected some notes of mine, and links to online tutorials, regarding matrices/matrix math tutorials and OpenGL, for a friend of mine. They may be of some use to you.

Java Advanced Imaging example of compositing two images

Since any and all examples and samples of JAI code seem hard as heck to find, after I figured out (I think) how to do it, I slapped together a minimal example case. Any and all comments on style and such, especially if I'm doing something wrong, are more than welcome. (source, 134 lines)


I've recently added the beginnings of an article on Swing GUI programming; at this point it's mostly an outline and some general advice.

Creating a Thread in Java

I've also added a very quick and simple example of how to create a thread in Java.

Java Swing Menu and Button actions

A straightforward example of implementing button 'Actions' - i.e. what happens when you click a Swing button. This also applies to Swing menus. (source, 98 lines)

Java and unsigned int, unsigned short, unsigned byte, unsigned long, etc. (Or rather, the lack thereof)

An explanation of how to deal with Java's lack of unsigned integer types.

Java and unsigned types.

Java Swing dialogs

An explanation of how to use a Java Swing JDialog.


Java Swing JTabbedPane

A straightforward example using the Swing JTabbedPane. (source, 79 lines)

Java Sockets Examples

A series of simple examples of using Sockets in Java.


Simple Chat One

The first in a series of examples of more complex uses of sockets in Java. In this example, we show how to create a (very) simple chat server.

Simple Chat One

Port Forwarder

A simple application to forward socket connections from one IP/port to another. This was a quick hack for a friend to allow them to inspect what was going on in some http transactions. It is provided here for whatever use you may make of it.

Port Forwarder

sean at guild dot net

Last modified: Thu Feb 3 22:09:14 EST 2011