Zurück zu Willert.de

Generating a Standolone Model in Java

Rhapsody Model or Codegeneration topics

Generating a Standolone Model in Java

Postby DjCisco » March 4th, 2013, 5:51 pm

Hallo Everybody,

I am starting to generate code with Rhapsody for Java.

I have created a very simple Model that that counts second and outputs the seconds in the command line. See Screenshots

I am able to compile and run the model from Rhapsody. I know wish to run the model without Rhapsody. How can I achieve this?

any help is greatly appreciated
regards

Fracisco
Attachments
Rhapsody.png
Screenshot Rhapsody Model
Rhapsody.png (109.13 KiB) Viewed 11435 times
DjCisco
 
Posts: 4
Joined: June 28th, 2011, 9:07 pm

Re: Generating a Standolone Model in Java

Postby Skywalker » March 30th, 2013, 3:16 pm

The answer to your question, "the solution" is more or less around the corner.
Looks like you just missed the link to it. :(

Your model "SecondsCounter" contains a component named "DefaultComponent" and that one contains a configuration named "DefaultConfig". That means a lot... ;)

Rhapsody uses the name of the component to do several things: :idea:
- use it as the name of the subdirectory within your project, containing generated configuration specific directories
(one component may contain multiple configurations of a component for different purposes, e.g. distinguish between one with and one without animation instrumentation in the generated code)
- use it as the name of the generated batch script, which sets the CLASSPATH and which either invokes the java compiler or runs the executable (based on command line option)
- use it to construct the name of the finally compiled java executable (e.g. "MainDefaultComponent")

Rhapsody uses the name of the configuration(s) for creating directories to finally store things: :idea:
- use it as the name of a nested directory (subdirectory of component directory) in a Rhapsody project containing generated artifacts like class files, batch files and java executables
(again: one component may contain multiple configurations of a component for different purposes, e.g. distinguish between one with and one without animation instrumentation in code)

:arrow: In your case this means, that:
- you should find a directory named "SecondsCounter" containing the Rhapsody project with all generated artifacts in nested directories.
- this directory will therefor also contain a subdirectory named "DefaultComponent" (according to the name of the component in your model)
- the subdirectory "DefaultComponent" will contain another nested directory named "DefaultConfig" (according to the name of the only configuration within the component in your model)
- the nested subdirectory "DefaultConfig" will contain the generated code in hierarchical subdirectories, which align with your package structure in the model (e.g. "counter.class" may be in another subdirectory "Default")
- the nested subdirectory "DefaultConfig" will also contain the batch script "DefaultComponent.bat" which will be used from within Rhapsody to either invoke javac in order to compile the generated classes, or in order to run the generated "MainDefaultComponent.java"
- if you have a closer look into "SecondsCounter\DefaultComponent\DefaultConfig\DefaultComponent.bat" you will learn how to invoke the generated executable outside of Rhapsody.

The easiest way would probably be opening a command line window, then changing to your configuration directory and finally typing "DefaultComponent.bat run MainDefaultComponent", since the batch script will set the required CLASSPATH in order to find all involved resources. You could also create an additional script which either invokes the above one, or which calls the relevant parts of the above one. :thumbup:

In general I recommend to use more spelling names like "SecondsCounterTest" instead of "DefaultComponent" or "JavaRelease" instead of "DefaultConfig" in order to be able to easily identify the generated artifacts. :!:

May the force and Rhapsody be with you,
Luke. :wave:
May the force be with you ...
Skywalker
 
Posts: 74
Joined: October 31st, 2007, 5:09 pm
Location: Milkyway, classic 9-planet solar system

Re: Generating a Standolone Model in Java

Postby DjCisco » November 25th, 2013, 4:06 pm

Hi Sykwalker,

thankd for your reply , I actually missed your reply, because I was able to solve the issue way before you answered.

I just came back to the forum and read your answer,and I am interested in further undertsasnding ýour replay.

Firts of all se below my solution to the Java standaloen executable problem.

1. Copy the Lib Folder "C:\Program Files\IBM\Rational\Rhapsody\7.6.1\Share\LangJava\lib"folder in the folder where the code of the application shall be generated
2. Modify the FrameworkNoneJars property in the Configuration of the Component: Make the paths to the .jars relative and not absolute "lib\oxf.jar; lib\anim.jar" etc....
4. Build the Model
3. create a batch file the folder where the application was generated with the following content: <NameOfTheBatFileCreatedByRhapsody.bat>run <MameOfYourMainClass>
Now you can simply zip the complete folder and distribute it to anyone, an the model will run.

As you can see first of all I have to copy the java libraries to the application folder, is there a way to avoid this? and second I have tu manually create the Batrch file that you mentioned, rhapsody is not creating the batchfile for me, ( how do I achieve that).

Thanks for your Help
DjCisco
 
Posts: 4
Joined: June 28th, 2011, 9:07 pm


Return to Modelling with Rhapsody

Who is online

Users browsing this forum: No registered users and 2 guests

cron