University
| Up | Oberon
| Russian Oberon
Page | Author | Tetris
| Ticker | Download
J( )B
Russian version
Source language | Oberon-2 |
Target language | Java Virtual Machine (JVM) byte code (.class files) |
J( )B compiler execution environment | Windows-95, Windows NT (console application) |
Applications, compiled by J( )B, execution environment | Any, Java Virtual Machine supporting platform |
Applets, compiled by J( )B, execution environment | Any Internet browser with Java support. Appletviewer from Java Development Kit (JDK) |
|
|
System requirements | Less than 1MB of memory for compilation; ~ 500K on disk |
Libraries |
|
University | Up | Oberon | Russian Oberon Page | Author | Tetris | Ticker | Download J( )B
J( )B is distributed as a single self-extracting archive.
Let source code located in file hello.o:
MODULE Hello; IMPORT javalang, Out; PROCEDURE main*( VAR args : ARRAY OF javalang.PString ); BEGIN Out.String("Hello, World!"); Out.Ln; END main; END Hello.
Compilation:
C:\JOB\EXAMPLES\HELLO>job hello.o JOB(tm) Oberon-2/JVM compiler. Strawberry version 0.75 (c) 1998 S.Sverdlov Module Hello Code size 17 Press <ENTER> |
Compiler created two files: Hello.class and Hello.dfn. Now, run program (Hello.class):
C:\JOB\EXAMPLES\HELLO>java Hello Hello, World! C:\JOB\EXAMPLES\HELLO> |
Good!. For compilation and execution of our program we used files job.bat and java.bat.
Look at files Hello.dfn and Hello.class:
Hello.dfn is ASCII-file:
DEFINITION Hello;
IMPORT javalang;
PROCEDURE main( VAR args : ARRAY OF javalang.PString );
END Hello.
Class file is binary. It is disassembled:
Compiled from hello.o public class Hello extends java.lang.Object { public static void main(java.lang.String []); /* Stack=1, Locals=1, Args_size=1 */ public Hello(); /* Stack=1, Locals=1, Args_size=1 */ Method void main(java.lang.String []) 0 ldc #5 <String "Hello, World!\0"> 2 invokevirtual #8 <Method java.lang.String.toCharArray()[C> 5 invokestatic #10 <Method Out.String([C)V> 8 invokestatic #12 <Method Out.Ln()V> 11 return Method Hello() 0 aload_0 1 invokenonvirtual #15 <Method java.lang.Object.<init>()V> 4 return }
This is the first applet compiled by J( )B .
MODULE BlackSquare; IMPORT app:=javaapplet, awt:=javaawt; TYPE App* = RECORD (app.Applet) END; PROCEDURE ( VAR a : App ) paint*( g : awt.PGraphics ); BEGIN g.fillRect(30,30,140,140); END paint; END BlackSquare.
Black Square is a famous picture of Kasimir Malevich.
Now, compilation:
C:\JOB\EXAMPLES\BSQUARE>job black.o JOB(tm) Oberon-2/JVM compiler. Strawberry version 0.75 (c) 1998 S.Sverdlov Module BlackSquare Code size 31 Press <ENTER> |
For the running Black Square applet use the appletviewer program from JDK. As parameter for appletviewer it is possible to specify the source code file, if this file contains <APPLET> tag:
(* First JOB compiled applet! "Black Square" Designed (1913) by Kasimir Malevich Programmed (2.03.98) by S.Sverdlov <APPLET code="BlackSquare_App" width=200 height=200> </APPLET> *) MODULE BlackSquare; ........
Run appletviewer (av.bat batch file):
C:\JOB\EXAMPLES\BSQUARE>av black.o |
After that on the screen there is such window:
The Oberon
Webring Navigator
Skip
Prev | Prev
| Next
| Skip
Next | Random
| Next
5 | List
Sites | Join
S. Sverdlov c3c@uni-vologda.ac.ru July 1998 |