Contents | Prev | Next | Index


A first Example

Canterbury Oberon-2 for Java can be easily called from a simple command prompt. For example, in order to compile and execute the Slides.java 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\obn\samples\slides>java mhc.obn Slides -m -r
Oberon-2 2.5.xx (c) 1998 Mill Hill & Canterbury Corporation, Ltd.
Unlicenced time-limited evaluation version
Compiling: C:\COM.webcom.mhc\mhc\runtime\obn\SYSTEM.obn
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.obn
Compilation done: Slides.obn

C:\COM.webcom.mhc\mhc\obn\samples\slides>javac Slides.java -nowarn

C:\COM.webcom.mhc\mhc\obn\samples\slides>appletviewer Slides.html
C:\COM.webcom.mhc\mhc\obn\samples\slides>

As can be seen, the command

java mhc.obn Slides -m -r

causes the file Slides.obn to be compiled into various *.java files:

Slides.java

Slides_ClickAnimation_init_Frame.java

Slides_ClickAnimation.java 

The -m switch tells the compiler also to recompile other imported Oberon-2 files if they are updated. This is like a Make-utility for Oberon-2 files integrated into the Oberon-2 compiler. The -r switch causes the compiler to write the runtime classes into the current working directory.

The command

javac Slides.java -nowarn

gets the *.java files translated into the final byte code:

Slides.class

Slides_ClickAnimation_init_Frame.class

Slides_ClickAnimation.class

Module Slides.obn has an Oberon-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 an 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 Oberon-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