Page tree

MagicDraw 2022x Documentation

On this page:

By default, JRuby is not included in the modeling tool, however, you can add it manually. In addition, you can also install Gems for JRuby.  

Adding JRuby to the modeling tool

To add JRuby to the modeling tool

  1. Copy the JRuby engine jar file (e.g. jruby-complete- to <tool_installation_directory>\plugins\com.nomagic.magicdraw.automaton\lib.
  2. Add the entry below to the file <tool_installation_directory>\plugins\com.nomagic.magicdraw.automaton\enginedescriptor.xml.

    <void method="add">
    	<object class="com.nomagic.magicdraw.automaton.EngineDescriptor">
    		<void property="extensions">
    			<object class="java.util.ArrayList">
    				<void method="add">
    		<void property="jars">
    			<object class="java.util.ArrayList"/>
    		<void property="name">
  3. Append a library entry in file <tool_installation_directory>\plugins\com.nomagic.magicdraw.automaton\plugin.xml.

    <library name="lib/jruby-complete-"/>

Installing Gems for JRuby

To install a gem for Ruby engine inside MagicDraw

  1. Open the command line.
  2. Go to the folder <tool_installation_directory>\plugins\com.nomagic.magicdraw.automaton\lib.
  3. Enter the following command to install a gem.
java -jar jruby-complete-<version>.jar -S gem install [--user-install] <gem name1> <gem name2> ...
  • <version> is the JRuby version, e.g.
  • <gem name> is the name of a gem.
  • The three dots (...) mean that you can type a list of gem names there.

Once the gem has been installed, you can use it in the MagicDraw Macro Engine. The example below shows how to create a macro that can generate a unique ID by using a gem.

require 'java'
require 'rubygems'
require 'uuid'
Application = com.nomagic.magicdraw.core.Application
uuid = Application.getInstance().getGUILog().log(uuid.generate);

To install a gem for the existing Ruby environment on your machine and use it in the Macro Engine

  1. Add the following properties to specify the home and library of JRuby in <tool_installation_directory>/bin/ under JAVA_ARGS section (assuming you have JRuby installed in C:/jruby- on your machine).
-Djruby.home\="C:/jruby-" -Djruby.lib\="C:/jruby-"

For example:

..JAVA_ARGS=-Xmx800M -Djruby.home\="C:/jruby-" -Djruby.lib\="C:/jruby-"

     2.  Change the JRuby library path to navigate to your jruby.jar in <tool_installation_directory>/plugins/com.nomagic.magicdraw.automaton/plugin.xml.

... <library name="c:/jruby-"/>
  1. The command in this section should run in <tool_installation_directory>/plugins/com.nomagic.magicdraw.automaton/engine.
  2. If you have a whitespace in the property file path, you need to type a double quote to wrap both the property and its value, for each property, for example:
    -Djruby.home=C:/my white space/jruby-" “-Djruby.lib=C:/my white space/jruby-
  • No labels