C212 System notes

  1. Printing
    1. Printing pages on this web: This web uses HTML frames so the contents stay visible on the left. To print the contents of the right frame, you may have to select the frame by highlighting some text in the frame, and then issue the print command.
    2. Printing files on STC machines: If you have a plain text file you want to print on an STC machine, use DrJava or Start > Programs > Utilities > Accessories > Notepad. You have to open the file or paste what you want to print. Notepad uses by default a large font that gives you about 70 characters per line, but you can use Format > Font to select a smaller font. Do not use the DOS print command, which causes the command prompt window process to hang, or word processors such as Word or Write, for they do not by default use a mono spaced (fixed character width) font, and may do other strange things that mess up indentation or worse.
  2. DrJava
    1. With the otherwise-good default font, 0 (zero) and O (capital letter O), look identical.
    2. The fastest way to try out corrections to a program is press the F5 key (shortcut for compile all). This will automatically reset the interactions window, killing any process and associated frame window that may be running at the time, so you generally do not have to bother closing your program frame windows. If the interactions window says the compilation was successful, to start your program again the same way you did before, click the Interactions tab and press the up-arrow return keys to automatically retrieve your last interaction (generally of the form new classname( arguments)) and run it.
    3. As soon as the compilation tab indicates that the compilation was successful, you can click on the interactions tab to try your program again. You do not have to wait for the hour-glass cursor to turn back into an pointer.
    4. Closing the frame stops a FrameWindowController program without resetting the DrJava console window, allowing you to inspect console error messages. The reset and compilation operations also stop the program, but clear the console as well.
    5. When the begin method of a FrameWindowController program returns, the process dies as far as DrJava is concerned (though listeners installed for the frame process are still active). This means the DrJava debugger cannot be used after the begin method returns. To keep it from returning, insert the following as the last line in the begin method body:
      try { wait(); } catch (Exception e) {}
      
  3. Objectdraw
    1. To turn an objectdraw program into an applet:
      1. Modify the applet class so it extends WindowController instead of FrameWindowController (and of course then recompile it).
      2. Copy objectdraw.jar to another file, say applet.jar.
      3. Assuming the current directory contains the applet class files (and no other class files), execute the command jar uf applet.jar *.class.
      4. In your html file, use an applet tag of the form <applet code =appletClass.class archive=applet.jar width= width height= height>, where appletClass, width , and height are the applet class name and applet dimensions.
    2. To turn an objectdraw program into an application: 
      1. Create an application class with a public static void main(String[] args) method. This method should process any application arguments, received in the args parameter, and then create an instance of the FrameWindowController class (which may the same class that contains the main method).
      2. Create a file named main-class.txt that contains exactly one line of plain text of the form: Main-class: <application class name>. (On some systems it is important that this line end with a newline character, while there are reports that some other systems do not like this extra character. Try it both ways if you have trouble.)
      3. Copy objectdraw.jar to another file, say application. jar.
      4. Assuming the current directory contains the application class files (and no other class files), execute the command jar umf main-class.txt application.jar *.class.
      5. You can now start your application on a Windows machine by double-clicking application.jar, or on a Unix system by executing the command java -jar application.jar.
    3. Bugs
      1. Sometimes a Text class object appears about 10 pixels too high when it is first drawn. If the canvas is redrawn for any reason, it goes to the right position.
      2. Sometimes the very end of a Text message will not be completely erased when setText replaces it with a new message. This appears to happen only if the canvas has not yet been cleared, so calling canvas.clear() at the beginning of the begin method body fixes this problem.
      3. getImage(String) sometimes returns an image before it can be used, which may result in a null pointer exception referring to the image. This seems to occur only when a large number of images, or particularly large images, are loaded.
    4. Strange features
      1. In a class that extends FrameWindowController, the begin method may be called before all instance variable initializers have run. Avoid this problem by initializing instance variables with assignments in the begin method if they are used in the begin method.
      2. The FrameWindowController canvas is not initialized until just before the begin method is called, so do not use initializers that directly or indirectly reference the canvas.
      3. Likewise, objectdraw needs time to set up its task management, so do not start an ActiveObject until the begin method has been called (even if you have no other use for FrameWindowController!).

      If you violate any of these "features", the most likely result is a null-pointer-exception from deep inside the objectdraw software.

  4. Miscellaneous
    1. If you are given an executable jar that should start by double clicking it and this does not work, it is probably because Windows has lost track of how to start an executable jar (which it is supposed to learn when the SDK is installed). Another way to run an executable jar is to open a command window and issue the command java -jar <jar file name>. The jar file name must be fully qualified (a complete path from a drive root), or you can change to its directory with the cd command.
    2. If a compiler error message doesn't make sense, look for later ones that do. Usually when you make a mistake you expect the obvious error messages first, followed frequently by derivative messages that make little or no sense. In Java, some derivative message that didn't make sense may appear first.
    3. If you refer to a class defined in a file that has not been compiled yet, the type checker will extract type information from the uncompiled source file without checking that it makes sense. If the type information includes a non-existent type (perhaps because you spelled it wrong or failed to import or qualify it as necessary), you will get a type error in the file being compiled without mention of the real problem in the uncompiled file.
    4. The jar command is DANGEROUS. If you make the mistake of typing jar -cf *.java, instead of jar -cf <jar file name> *.java, the first java file, in alphabetical order, will be replaced by a jar of the same name containing the remaining files. In this and many other situations, you will be sorry if you did not keep a backup copy of your java files. If, when you realize you did not create a jar file, you issue the right jar command, but without fixing the trashed java file, and then submit the jar file without checking that its contents compile, you will lose credit for the assignment because your submission is missing the first java file. Before submitting, always unjar your submission into a temporary directory and see that the whole thing compiles. (The computing word, especially system development and maintenance, is full of tools that are dangerous. It is a very rewarding business, but small mistakes can be costly. Hence it is vital that you learn habits of being very detail oriented, checking your work often, and keeping backups of everything.)
More system notes will appear in this space as additional anomalies are discovered.