Articles by Greg Travis

A 3D Exploration of the HTML Canvas Element
A Server-Side Assist for Loading Client-Side JavaScript Code
Active Links / Rediscover (and Structure) CGI with a Simple Link Technique
An Easy JDBC Wrapper
Applet Terminals
Asynchronous Event Handling
Blocking Queue
Build a Reflection-based Interpreter in Java
Build a Simple WYSIWYG Web Page Editor (Build-a-Page)
Build an Embedded Array Language in Java
Build your own Java library
Building a Java Chat Server
Create BitInputStream and BitOutputStream Classes
Creating a Custom Java Console
Creating a More Responsive User Interface in JavaScript
Creating a Single-Instance Server
Creating modular interactive user interfaces with JavaScript (Rearrange Your Page)
Cross the Gap Between PHP and Java
Double-Buffer Applet
Emacs a top-notch Java IDE? You bet!
Enable Cross-platform File Locking with a Lock Server
Encrypted Class Files
Encrypted Preferences in Java
Floating Applet
Getting started with new I/O (NIO)
How to lock down your Java code (or open up someone else's)
Implement a Browser Command Line with JavaScript
Inter-applet Communication
JDK 1.5 Preview: Addition of Generics Improves Type Checking
Java Web Start: One-Touch Application Deployment
Minimize Java Distributions with an Automated, Custom JAR File
MultiApplet
PHP Source Filtering: Adding New Features to PHP Using Source Filtering
Passing Objects Between Threads
Perl-like Data Structures in Java
Set Up a Certification Authority for Java-based Systems
Simulating 'select'
Simulating Weak References In Java
Store objects using the Preferences API
String-Caching a Message Protocol
Support Any Image Format with the JDK 1.4 ImageIO Library
The Persistent Hashtable: A Quick-and-Dirty Database
Thread pool
Three Java Variants Extend the Language
Understanding the Java ClassLoader
Use Callbacks to Isolate Concurrency Bugs
Use select for high-speed networking
User annotations in Ajax (Yellow Stickies)
Using JSSE for secure socket communication
Using RPM
Write Efficient Java Apps Using Native Data Structures with JNI
Writing Data Safely with the CKPTFile Class
Writing a Seamless Looper in Java, Part 1: Playing Audio
Writing a Seamless Looper in Java, Part 2: Playing Audio
 
 
Creating a More Responsive User Interface in JavaScript
Learn how to increase the perceived responsiveness of a complicated user interface using JavaScript. This is the earliest article I know of about the technique that came to be called AJAX.
Read on-line
PDF
Published by
 
Active Links / Rediscover (and Structure) CGI with a Simple Link Technique
CGI is the most widely used protocol for Web programming, but it doesn't check types or variable declarations and doesn't have function calls. You can work around these weaknesses by encoding function calls directly into Web links easily creating active links—and you can do it in PHP, Perl, JavaScript, and Java.
Read on-line
Published by
 
Applet Terminals
Find out how to have Applets with Multiple Locations on a Page.
Read on-line
Source code
Published by
 
Asynchronous Event Handling
Get rid of nasty applet pauses.
Read on-line
Published by
 
Implement a Browser Command Line with JavaScript
AJAX techniques offer sophisticated GUIs on the web, but sometimes you need to execute commands at the command line. This article demonstrates how to build a custom command line you can add to your user interface -- and even get a free run-time scripting engine. while it's executing a main program file. Implementing an include directive on the server side is a simple technique for getting around this limitation.
Read on-line
Source code
Published by
 
Create BitInputStream and BitOutputStream Classes
Although the JDK 1.4 has many Stream classes, it doesn't contain classes for reading and writing single bits. Extend your tool set by creating these BitInputStream and BitOutputStream classes.
Read on-line
Published by
 
Blocking Queue
In a multi-threaded environment, the blocking Queue is a basic technique with broad applications. This article shows you what it is for, and how it is implemented.
Read on-line
Published by
 
Build a Simple WYSIWYG Web Page Editor (Build-a-Page)
Explore a simple Asynchronous JavaScript + XML (Ajax) system that lets your users assemble pages by adding and arranging pre-made widgets. Many sites provide this kind of functionality, but this easy-to-use system lets you do it on your own site and provides a simple library for creating new widgets. This article describes a simple system that lets users of your Web site build their own Web pages. With it, they can place text and images on their page, arrange them to their liking, and save their work. The code in this article stands alone, without any third-party libraries. It's not necessarily what you would want to do in a real-world environment, but it covers a lot of ground for investigating implementation techniques. Check out my podcast about this article.
Read on-line
Source code
Published by
 
Use Callbacks to Isolate Concurrency Bugs
By restricting all object data access to a callback mechanism, a Java server can contain all concurrency issues in a single place, making it much easier for you to see if concurrency constraints have been violated.
Read on-line
Published by
 
Set Up a Certification Authority for Java-based Systems
A certification authority can provide authenticating certificates, which enable secure Web transactions in a system of trust that doesnt require any pre-built software or commercial services.
Read on-line
Source code
Published by
 
Building a Java Chat Server
In this tutorial, you'll build a simple, centralized, connection-oriented Java server. In doing so, you'll learn a basic framework that you can use when creating such a server, using time-honored techniques that work well in many situations.
Read on-line
Source code
Published by
 
Writing Data Safely with the CKPTFile Class
Making changes to memory-mapped files is a delicate operation, but far from impossible. Learn how to make safe, atomic changes to memory-mapped files using a checkpoint system that will leave your applications fast and robust and your data impervious to corruption.
Read on-line
Source code
Published by
 
Understanding the Java ClassLoader
This tutorial will teach you what a ClassLoader is, and why it is a crucial part of the Java virtual machine. It will also teach you how to create a custom ClassLoader, allowing you to extend the functionality of the JVM in powerful ways.
Read on-line
Source code
Published by
 
Build a Reflection-based Interpreter in Java
Java's support of reflection enables you to create an interpreter that executes commands interactively. This article demonstrates how to build a reflection-based system that allows simple scripting of Java programs without having to install a special-purpose scripting language. It also provides a downloadable sample program.
Read on-line
Source code
Published by
 
Creating a Custom Java Console
This article will tell you how to create your own browser console, some of the pitfalls you may encounter, and a few other interesting tidbits.
Read on-line
Source code
Published by
 
Build an Embedded Array Language in Java
This article describes a generalized system for dealing with multidimensional arrays of data. It lets you transform and extract slices of data along various axes with very little code, in the style of the programming language APL. And you're not limited to numerical data; you can generalize systems such as this to any kind of tabular data.
Read on-line
Published by
 
Double-Buffer Applet
Get rid of that annoying flicker in graphics-intensive applets!
Read on-line
Published by
 
Encrypted Class Files
With a decompiler, anyone can look inside your code and use it for their own purposes. Fortunately, the very flexibility that makes Java easy to steal also makes it relatively easy to protect using encryption.
Read on-line
Source code
Published by
 
Encrypted Preferences in Java
This article considers the technique of automatically encrypting data before storing it in the preferences database. This permits applications to use the Preferences API even for sensitive data, such as passwords and personal information.
Read on-line
Source code
Published by
 
Floating Applet
Get your applet off the page and into its own window!
Read on-line
Source code
Published by
 
JDK 1.5 Preview: Addition of Generics Improves Type Checking
Generics is one of the hottest features of the upcoming JDK 1.5 release. This article describes the new generics feature by investigating the example pre-release implementation provided by Sun. You'll use the generics feature to create an extensible multimedia application, and show how generics make the code simpler.
Read on-line
Published by
 
A 3D Exploration of the HTML Canvas Element
The HTML Canvas, an element of the upcoming HTML 5 specification, allows you to efficiently draw arbitrary graphics at the primitive or individual pixel level. Find out how to implement a 3D rendering using the HTML Canvas.
Read on-line
Source code
Published by
 
Support Any Image Format with the JDK 1.4 ImageIO Library
Learn to design and implement a load/save dialog box that can read and write images in any format.
Read on-line
Published by
 
Inter-applet Communication
Getting Them to Talk to Each Other.
Read on-line
Source code
Published by
 
Minimize Java Distributions with an Automated, Custom JAR File
Larger applications frequently get loaded down with a heavy burden of unused library files. Learn to create a custom classloader that automatically builds a JAR file that contains only the classes you need.
Read on-line
Source code
Published by
 
Emacs a top-notch Java IDE? You bet!
Emacs is one of the most popular development environments in the history of software programming, so it's no surprise that there are a number of excellent Emacs tools for Java programming. In this article, Greg Travis examines three of the best tools to alter your Emacs environment into a killer Java-language integrated development platform -- Java Mode, Hilit Java, and the showpiece, the Java Development Environment for Emacs. He describes what they do, how to use them, and how to get them.
Read on-line
Published by
 
Build your own Java library
In this free, dW-exclusive tutorial, you will learn how the Java language can help you make a good, reusable library. The tutorial covers a few key principles of good library design and presents efficient ways to implement each. To illustrate the concepts, the tutorial walks through the design of a simple library.
Read on-line
Published by
 
An Easy JDBC Wrapper
JDBC provides a powerful, comprehensive interface for accessing databases from Java programs. For smaller projects, JDBC can seem overwhelming, driving some programmers to avoid using a database altogether. This article describes a simple wrapper library that makes basic database usage a snap. You'll find yourself wanting to use JDBC for every program you write.
Read on-line
Source code
Published by
 
A Server-Side Assist for Loading Client-Side JavaScript Code
JavaScript lacks a function for loading and executing a library file while it's executing a main program file. Implementing an include directive on the server side is a simple technique for getting around this limitation.
Read on-line
Source code
Published by
 
Using JSSE for secure socket communication
This tutorial provides cookbook-style instructions for creating and installing JSSE encryption keys in a client/server application environment. When you have completed this tutorial, you will know how to easily convert any existing client/server application to use encryption, as well as how to create a secure application from scratch.
Read on-line
PDF
Published by
 
Java Web Start: One-Touch Application Deployment
Distribute full Java applications to users as easily as you distribute applets.
Read on-line
Published by
 
Enable Cross-platform File Locking with a Lock Server
JDK 1.4 now comes with support for OS-level file locking. File locking, however, does not necessarily work the same on all platforms. A custom shared file locking server can overcome this obstacle to complete portability, and should be used for any system that needs reliable, portable file locking.
Read on-line
Source code
Published by
 
Writing a Seamless Looper in Java, Part 1: Playing Audio
Here are the basics of creating a utility class that can seamlessly play a looped sample over and over in continuous loops.
Read on-line
Source code
Published by
 
Writing a Seamless Looper in Java, Part 2: Playing Audio
Here are the basics of creating a utility class that can seamlessly play a looped sample over and over in continuous loops.
Read on-line
Source code
Published by
 
MultiApplet
Run Multiple Applets Inside an Applet Window.
Read on-line
Source code
Published by
 
Write Efficient Java Apps Using Native Data Structures with JNI
Sometimes Java's data structures use too much memory to store the data you need to store. In such situations, you can use the JNI native code interface to access native data structures. Find out how to use the STL in C++ to implement a space-efficient hashtable that works like a regular Java hashtable.
Read on-line
Source code
Published by
 
Getting started with new I/O (NIO)
The new input/output (NIO) library, introduced with JDK 1.4, provides high-speed, block-oriented I/O in standard Java code. This hands-on tutorial covers the NIO library in great detail, from the high-level concepts to under-the-hood programming detail. You'll learn about crucial I/O elements like buffers and channels, and examine how standard I/O works in the updated library.
Read on-line
Source code
Published by
 
How to lock down your Java code (or open up someone else's)
Whether you're patching in code from one of the many open-source libraries on the Web or making calls to common operating system routines, you inevitably spend some part of your week crunching code that you didn't write, and for which you may not have the source. When it comes time to debug this code, you'll need access to a good Java decompiler and the know-how to use it properly. At the same time, you'll also want to know how to protect your own code from prying eyes. For that, you need to know about obfuscation. In this beginner's guide to opening up and locking down Java code, Greg Travis walks you through the essentials of disassembling, decompiling, and obfuscating Java code, using examples from popular tools such as Mocha, HoseMocha, jmangle, and JODE.
Read on-line
Published by
 
Passing Objects Between Threads
Describes a simple technique (and some variations) for simple inter-thread communication.
Read on-line
Published by
 
Perl-like Data Structures in Java
Describes a generally useful data structure, inspired by Perl, that has some interesting uses for Java programming.
Read on-line
Published by
 
The Persistent Hashtable: A Quick-and-Dirty Database
Larry Wall, the creator of Perl, once said: "The three principal virtues of a programmer are Laziness, Impatience, and Hubris." The combination of these virtues is what makes it annoying to have to write something more than once. And the only way to remove this annoyance is to make yourself a simple useful library that you can reuse. This article describes the implementation of a simple library for doing something that many programs have to do: save data. It's not going to solve all of our data-saving needs, because, regardless of what some database vendors might tell you, there is no one piece of software that can properly handle every data-saving situation. The software we're going to be talking about is called a Persistent Hashtable, and it's going to fill a specific niche in the world of data-saving, which is a very broad world.
Read on-line
Source code
Published by
 
Cross the Gap Between PHP and Java
Using sophisticated application frameworks to build your network server applications is fine, but sometimes these frameworks are overkill. With a little communications programming between PHP and Java, you can establish an extensible layer that handles the annoying details of creating a custom network protocol.
Read on-line
Source code
Published by
 
Store objects using the Preferences API
The Preferences API -- a lightweight, cross-platform persistence API introduced in JDK 1.4 -- is designed to store small amounts of data (string, simple byte arrays, and so on.) and was not intended to be an interface to a traditional database. It can, however, be effective as a storage device if your data can be expressed as simple objects. This article offers an introduction to the API, explains how objects are stored, demonstrates the process in action, and provides a code library to do the work.
Read on-line
Source code
Published by
 
Creating modular interactive user interfaces with JavaScript (Rearrange Your Page)
Discover a technique that lets you move sections of a Web page using drag-and-drop functions. Different aspects of the interactivity are implemented separately and then composed into a unified whole, allowing for flexible customization that can make your Web users very happy.
Read on-line
Source code
Published by
 
Using RPM
No description
Read on-line
Published by
 
Use select for high-speed networking
Java uses an extremely elegant input/output (I/O) model, based on the idea of a stream. A stream is an object that produces or consumes a string of bytes. Streams can be chained together in conjunction with filtering routines and extended to handle other kinds of data. The stream model is very flexible, but not too fast. It's fine for many applications, but some systems require just about as much speed as the hardware can handle. Sometimes the stream model won't cut it.
Read on-line
Source code
 
Simulating 'select'
Learn two different ways to efficiently handle large numbers of InputStreams.
Read on-line
Source code
Published by
 
Creating a Single-Instance Server
This article shows you how to write a single class file which implements both the listener and processor portions of a TCP/IP server.
Read on-line
Source code
Published by
 
PHP Source Filtering: Adding New Features to PHP Using Source Filtering
The technique of source filtering lets you preprocess your code before execution. This can be really useful if you want to add features to the language you are using, without having to change the language itself. Very few languages support this, but PHP is one of them. This article will take you through the theory and practice of PHP source filtering, and show some useful examples.
Read on-line
Source code
Published by
 
User annotations in Ajax (Yellow Stickies)
The ability to add notes and comments to your Web site can be a powerful and attractive feature for users. This tutorial demonstrates how to implement an Asynchronous JavaScript and XML (AJAX)-based user annotation system in the form of yellow sticky notes that sit on top of regular Web page content. The only additional, required configuration is a back-end Perl script that stores the annotations
Read on-line
Source code
Published by
 
String-Caching a Message Protocol
Learn how to get potentially large savings in the efficience of your custom network protocol.
Read on-line
Published by
 
Thread pool
Under many Java implementations, creating and destroying threads very fast can drastically reduce performance. Using a Thread Pool can get around this problem.
Read on-line
Source code
Published by
 
Three Java Variants Extend the Language
Learn about three of the most promising Java variants--how they work, what their features do, and how you can integrate them into your development environment.
Read on-line
Published by
 
Simulating Weak References In Java
The current browser implementation of Java does not support Weak References. It might be added in the future, but until then, you can use this trick to get some of the useful features now.
Read on-line
Published by