EXAMPLES

PIC 20B/1, Fall 2001


  1. An excellent example of a FileCopy program created by D.Flanagan (see Java Examples in a Nutshell). The program uses some of the Java Input/Output Streams along with java.io.File class. Please note its very elaborate exception handling, which makes it essentially longer then the bare bones File Copy example from the Java Tutorial.
  2. An example of ping utility used to elicit response from a specified network host or network gateway.
  3. An example of an extremely simple EMAIL client.
  4. A sketch of a complete Client/Server application. Two versions of server are presented: single-threaded (Server1) and multi-threaded (Server2).
  5. An example that shows how to execute a native OS program from within a Java program. This example also demonstrates how to read output of that native program back into your Java program. Note that this particular example runs UNIX /bin/who command, which can be replaced with, say C:\windows\notepad.exe or any other program you actually wish to start from within Java.
  6. The Holy Grail of Java Applets: an applet that can do simple file I/O on the server. It uses FTP to do the actual I/O. The code is written by Peter van der Linden and Robert Lynch, license: GPL.
  7. The following program is based on an example from C.Berg, "Advanced Java" (see chapter 4 - "Java Security"). It demonstrates how to use Thread Groups to segregate rights within your program. GremlinWatcher is our own security manager which implements custom security policy. BadGremlin and GoodGremlin are two services that can be loaded and started dynamically by the main driver of our program - GremlinWatcher. Note that GremlinWarcher uses Java reflection capabilities in order to load and process new classes dynamically.


Last modified on by fedandr@math.ucla.edu.