Introduction
I have been to Bochum before but I normally don’t use Rhapsody in Java… So still a “first”. I can program Java, however! Not as good as C but I’ll manage.
And I have to say… I like RiJ! It is really, really easy to use. Rhapsody brings its own Java so there is no need to install anything! Itjust works.
It’s a long time ago that I gave a training where all students had their “Hello World” running in minutes.
The Framework is, of course, much simpler, Java already brings everything you need to run UML generated code.
The only thing the Framework needs to do is to proces the events and the timers.
Issues
There were not many issues with getting stuff to work. The most important thing was an issue when you installed Rhapsody and selected the wrong java Directory. But this is easy to repair.
in your Rhapsody Share directory there is an “etc” directory. In that directory you will find two batch files: jdkmake.bat and jdkrun.bat. These files have paths in them that need to point to the JDK that Rhapsody delivers by standard.
Hello World Example
The first program you make in any new language is “Hello world”. So we will creata a Java Hello world.
Open Rhapsody in Java and create a new project. Call it “HelloWorld” and create it in a directory where you can find it back. (Rhapsody wants to create projects in the Rhapsody data directory by default.
When the project is created you will see an empty Object Model Diagram. Draw a Class (either select the Class from the drawing menu or right click in the diagram and select “Class”. Then draw the class. Cal it “Hello” and give it a constructor, do not give it parameters.
In the constructor write ( in the Tab “Implementation” ) the following:
System.out.println”Hello World”);
Apply the change. Then we need an Object, right click on the Class “Hello” in the Rhapsody Model Browser and select “Make an Object”.
Then press “GMR” (Generate Make Run) and presto: it works!
Happy Modeling with Rhapsody!
Walter vand er Heiden (wvdheiden@willert.de)