Contents | Prev | Next | Index
Canterbury Modula-2 for Java can be easily called from a simple command prompt. For example, in order to compile and execute the Slides.mod sample on a Windows-95 system, just open a DOS-prompt and enter the following commands (shown here in red color):
C:\COM.webcom.mhc\mhc\mod\samples\slides>java mhc.mod Slides -m -r Modula-2 2.5.xx (c) 1998 Mill Hill & Canterbury Corporation, Ltd. Unlicenced time-limited evaluation version Compiling: C:\COM.webcom.mhc\mhc\runtime\mod\SYSTEM.mod Importing Java class: java.applet.Applet Importing Java class: java.lang.Runnable Importing Java class: java.lang.Thread Importing Java class: java.awt.Image Importing Java class: java.awt.Graphics Importing Java class: java.awt.Event Importing Java class: java.lang.String Importing Java class: java.lang.RuntimeException Compiling: Slides.mod Compilation done: Slides.mod C:\COM.webcom.mhc\mhc\mod\samples\slides>javac Slides.java -nowarn C:\COM.webcom.mhc\mhc\mod\samples\slides>appletviewer Slides.html C:\COM.webcom.mhc\mhc\mod\samples\slides>
As can be seen, the command
java mhc.mod Slides -m -r
causes the file Slides.mod to be compiled into various *.java files:
Slides.javaSlides_ClickAnimation_init_Frame.java
Slides_ClickAnimation.java
The -m switch tells the compiler also to recompile other imported Modula-2 files if they are updated. This is like a Make-utility for Modula-2 files integrated into the Modula-2 compiler. The -r switch tells the compiler to put the runtime output files (SYSTEM*.java) into the current working directory.
The command
javac Slides.java -nowarn
gets the *.java files translated into the final byte code:
Slides.classSlides_ClickAnimation_init_Frame.class
Slides_ClickAnimation.class
Module Slides.mod has a Modula-2 class type called ClickAnimation extending the imported class java.applet.Applet. It also declares some type-bound procedures resulting in an override of some inherited methods. In order to run ClickAnimation, an applet-tag has to be declared in a HTML-document. In this case, file Slides.html has an applet-tag (highlighted in green) as follows:
Slides.html <HTML> <HEAD> <TITLE>A simple click animation applet</TITLE> </HEAD> <BODY> <P> <APPLET CODE="Slides_ClickAnimation.class" CODEBASE=. NAME="A simple click animation applet" WIDTH="170" HEIGHT="170"> </APPLET> </BODY> </HTML>
Calling this file using the JDK appletviewer utility:
appletviewer Slides.html
will launch the Slides_ClickAnimation.class.
Contents | Prev | Next | Index
Canterbury Modula-2 for Java (Last documentation update
Feb 8, 2000)
Copyright © 1998 Mill Hill &
Canterbury Corporation, Ltd. All rights reserved
Please send any comments or corrections to
mhc@webcom.com