Start the server, if it isn't already running, and specify a port on the command line:
$ java LockServer 5678
Listening on port 5678
Once your server is running, you can run the test program called Test.java. This program lets you specify the various locking parameters on the command line, like this:
$ java Test <host> <port> <filename> <position> <size> <shared> <try>
The test program will acquire the lock if it can, and then wait for you to press Return. When you press return, it will release the lock. Try running multiple copies of Test in different windows to see the locks interact.
Reconcile Cross-platform Differences
A lock server can make up for differences between operating systems or Java implementations. The file-locking specification allows each implementation to choose whether its locks are process-wide or system-wide, which can play havoc with a program that needs system-wide locks. In these situations, you can use a lock server to replace the functionality missing from the underlying implementation.
This approach is an excellent way to deal with cross-platform differences. Just write it yourself! If you run your program on a system that happens to have system-wide locking, the lock server will still work correctly.