next up previous contents
Next: 3.2.4 C# code synthesis Up: 3.2 HelloWorld Example Previous: 3.2.2 C++ code synthesis   Contents

3.2.3 Java code synthesis

SCC is also able to synthesize Java code from DCharts models. The Java code requires JDK (Java Development Kit) to compile to Java byte-code. The most recent version of JDK is downloadable from:

http://java.sun.com/
(JDK 1.4 or above is recommended.)

The following command synthesizes Java code for HelloWorld.des:

scc -ljava HelloWorld.des

The following message is printed out to the console:

-----
Time spent on compilation:         0.007 (sec)
File(s) generated:                 HelloWorld.java
-----
Command to compile the source:     javac HelloWorld.java
Command to run the compiled code:  java HelloWorld
-----

HelloWorld.java is the only Java file for the model. It contains the definition of several classes. When it is compiled with javac, the following class files are produced in the current directory:

EventList.class
HelloWorld.class
Hierarchy.class
History.class
State.class
StateMachine.class
StringList.class

Among those class files, HelloWorld.class provides the entrance of the program. To execute it, use the following command:

java HelloWorld
(Note: the postfix of the main class file is removed.)

The result of the execution is as following:

    Hello World Example
['A'] > e
['B'] > exit

The -ext parameter is currently not supported for target code in the Java language. Later versions of SCC will add support for action code and guards. However, to provide this support, an interface between the Java code and the C library provided by Python is required, which makes the target code platform-dependent.


next up previous contents
Next: 3.2.4 C# code synthesis Up: 3.2 HelloWorld Example Previous: 3.2.2 C++ code synthesis   Contents
Thomas Huining Feng
2004-04-05