Sample Programs for Class 2

Several sample programs related to the material covered in Class2 are described below. You can download the zipfile containing them by clicking here

Run1.java

The Run1 program executes a native OS/2 program passed as a command line argument. To use it:
  • Compile (javac Run1.java)
  • Execute with parameters - java Run1 program-name
  • View Source

    Run2.java

    The Run2 program executes multiple programs whose names are given as command line arguments. Each program is started in a separate thread To use it:
  • Compile - javac Run2.java
  • Execute - java Run2 prog1 prog2 ...
  • To end - after all programs have finished, type q in the command window
  • View Source

    Sys1.java

    The Sys1 program demonstrates accessing java runtime environment properties. It displays the property for the currently installed JDK. To use it:
  • Compile - javac Sys1.java
  • Execute - java Sys1
  • To end - type q in command window
  • View Source

    Sys2.java

    The Sys2 program demonstrates enumeration class methods. It performs an enumeration on all system properties and then lists the property name and values to the standard output stream. To use it:
  • Compile - javac Sys2.java
  • Execute - java Sys2
  • View Source

    Parse1.java

    The Parse1 program demonstrates use of StringBuffer and StringTokenizer class methods. It tokenizes an input string and prints out each token. To use it:
  • Compile - javac Parse1.java
  • Execute - java Parse, when prompted enter input strings with tokens delimited by comma and/or space
  • To end - respond with empty line
  • View Source

    Browse1.java

    The Browse1 program demonstrates accessing an Applet. The Applet displays parameters passed to it by the invoking HTML. To use it:
  • Compile - javac Browse1.java
  • Execute - applet Browse1 browse1.html (or invoke from Netscape browser)
  • View Source