IBM Support

How to setup RoseRT for J2ME/KVM development

Troubleshooting


Problem

How to setup RoseRT for J2ME/KVM development

Resolving The Problem

QUESTION:
How do I configure Rational Rose RealTime for J2ME/KVM development?

ANSWER:
Rose RealTime supports J2ME/KVM development but there are some things that need
to be configured to allow this to happen. Default settings can be created and
saved as a framework like the example attached.

Before looking at the framework, there first needs to be some explanation of
the differences to standard Java and the J2ME (the Java Micro Edition
http://java.sun.com/j2me/).

The first difference is that the Virtual Machine support, J2ME code can be run
on the K Virtual Machine, which is a smaller target Java Virtual Machine (KVM
"Named to reflect that its size is measured in the tens of kilobytes"
http://java.sun.com/products/cldc/)

The next difference is the configuration, since we are after a smaller
footprint, the configurations used are strictly defined. The Connected Limited
Device Configuration (CLDC) is the one used for KVM applications. Then in
addition to the foundation configuration, there are supported Java API's such
as the Mobile Information Device Profile (MIDP).

For more detailed information, refer to the http://java.sun.com/j2me/.
Note: This Solution assumes that the user has the CLDC 1.0.3 configuration
installed to C:\j2me_cldc.

For this Solution, we will first build and run an application outside of Rose
RealTime, to get an understanding of what is required and to confirm that the
host configuration is correct (it is important to remember that if the user
can't build an application from the command line then neither can Rose
RealTime*).

Steps for Building On the Command Line:

1) Create a Hi.java file with the following code

public class Hi {
public static void main( String[] args ){
System.out.println( "Hi!" );
}
}

2) Build the code using the J2ME classes

javac -bootclasspath C:\j2me_cldc\api\classes Hi.java


3) Preverify the code (Note: this is required because, to keep KVM small, it
doesn't have the ability built-in to check the Java code at runtime. It is
expecting the Java code to be verified somewhere else before it is run i.e.
here)

C:\workarea>preverify.exe -classpath C:\j2me_cldc\api\classes -d preverified
Hi


4) Test the code

C:\workarea\>kvm -classpath C:\j2me_cldc\api\classes;C:\workarea\preverified
Hi
Hi!

Note: In the above the system path variable has been set, to enable the javac,
kvm and preverify commands to be run from the command line.


Steps for Building Using Rose RealTime:

Now that the environment has been tested, Rose RealTime can be configured to
build J2ME applications.

1) Before even starting Rose RealTime set ENABLE_CLDC_PROTOCOLS to true
(through the Windows Control Panel). This will enable the target protocols that
are required for visual debugging.

2) The Rose RealTime TargetRTS is provided as a jar file. Like the Java
bytecode that will be developed, this also needs to be preverified before the
KVM will accept it. One method is to create a "KVM" version as below:

cd %ROSERT_HOME%\RTJava

mkdir kvm

cd kvm

copy ..\classes.jar classes.jar

jar -xf classes.jar

preverify -classpath C:\j2me_cldc\api\classes -d preverified .

move tmpdir\com preverified\com

The result should be a preverified classes.jar and the com\rational\rosert
classes, located in %ROSERT_HOME%\RTJava\kvm\preverified.

*** Important Note - the above will need to be redone, after any Java related
toolset patches are applied ***

3) Confirm that Rose RealTime will build and run a standard Java application.
Copy the %ROSERT_HOME%\Examples\Models\Java\HelloWorldCapsule.rtmdl to a
workarea, build and run it.

4) A J2ME framework is attached but for interests' sake, this is how it is
created.

- Open the %ROSERT_HOME%\RTJava\TargetRTS.rtmdl
- "File->Export…" the model as a complete unit to the location that it will
be kept
- Open the framework and change rosert/classes in the Component View to point
to $(ROSERT_HOME)/RTJava/kvm/preverified/classes.jar
- The default RTJava Project has the following added to the CompileMakeInsert,
this will be inserted in the makefile of every component so that preverified
classes are generated.

COMPILE_TARGET = preverifyFiles
preverifyFiles: $(COMPILE_ONE_TARGET)
rtperl "$(ROSERT_HOME)/codegen/rm.pl" -f -R $compName/preverified
preverify -d $compName/preverified -classpath
"C:/j2me_cldc/api/classes;$(ROSERT_HOME)/RTJava/kvm;." ../$compName

- Save the framework model and using the File New dialog, create a framework
icon.

To use the framework attached, extract the contents of the zip file to the C:\
drive (it will appear as C:\120625925_J2ME_KVM). From RoseRT do the following:

- File->New to bring up the "Create New Model" dialog
- Press the "New Framework…" button, then "Next" after reading the "Framework
Wizard - Welcome"
- Enter the Framework Name: "J2ME KVM"
- Select the Model File: "C:\120625925_J2ME_KVM\J2ME_framework.rtmdl"
- Select the Document File: "C:\120625925_J2ME_KVM\J2ME.txt"
- Select the Icon File: "C:\120625925_J2ME_KVM\RTJava.ico"
- Press "Next" and "Finish"

Now the J2ME framework is available.

5) To use the framework.

Model the application as normal and create a component to build from (as in the
HelloWorldCapsule.rtmdl). The differences to build and run the component will
be as follows:

For the component to run, the following will need to be put into the Component
Instance Specification - Detail - Parameters. (Note: The location of the
individual preverified class will be unique for each instance, in this case the
"Hi" example)

-vm kvm.exe -classpath
C:\j2me_cldc\api\classes;$(ROSERT_HOME)\RTJava\kvm\preverified;
C:\120625925_J2ME_KVM\Hi\Hi\preverified; -heapsize 256K
com.rational.rosert.DebugApplication Hi -obslisten=30564

Also included in the attached zip file is a Hi.rtmdl which runs from the
C:\120625925_J2ME_KVM location.


* Note: A gotcha with the CLDC installation on Windows, the makefiles are in
Unix format and gnumake will fail when run from a DOS prompt, so run the
gnumake command from a Cygwin shell (Cygwin is a Unix environment which will
run under Windows, the web link is given in the CLDC release notes but its use
is not explained).





[{"Product":{"code":"SSSHKL","label":"Rational Rose RealTime"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"--","Platform":[{"code":"PF033","label":"Windows"}],"Version":"2002.05.00.305.000","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}}]

Historical Number

120625925

Document Information

Modified date:
16 June 2018

UID

swg21120832