How do I create a RTI Connext Java application in Eclipse?

Note: Applies to RTI Connext 4.x and above.

  1. Start Eclipse in the Java perspective.
  2. Right-click in the white area of Package Explorer and select New, Java Project
  3. In the New Java Project dialog, for the Project name, enter: MyDDSProject
  4. Click Finish. (This creates MyDDSProject in the Package Explorer directory. Under that is a src directory and JRE System Library resources.)
  5. Right-click on MyDDSProject and select Properties, Java Build Path. From the Libraries tab, select Add External Jars.... The Jar Selection file browser will pop up.
  6. Browse to the <RTI Connext installation directory>/class directory, select the nddsjava.jar file, click Open.
  7. Click OK. (Under MyDDSProject, you will see Referenced Libraries; under that is the nddsjava.jar that you entered above.)
  8. Open a command shell and change to the directory of the Eclipse workspace that you created (.../workspace/MyDDSProject/src) and create a DDS Java application:  
    1. Create your IDL file. In this example, we will assume the IDL filename is HelloWorld.idl.
    2. Run rtiddsgen as follows:
      rtiddsgen -language Java -example <architecture> HelloWorld.idl
    3. Verify HelloWorld*.java files are created.
  9. Back in Eclipse, right-click on MyDDSProject, Refresh. The MyDDSProject/src has a (default package) subfolder. Select (default package). The Java source files that you created with rtiddsgen are now visible in Eclipse. Make any updates to the HelloWorldPublisher/Subscriber.java files that you desire.
  10. Run the HelloWorldPublisher/Subscriber.java files:
    The PATH environment variable needs to be set before running the HelloWorld application.
  • Double-click (default package) to expand the folder
  • Select the file you want to run (such as HelloWorldSubscriber.java)
  • From the menu bar, select Run, Run Configurations…
  • Select the Environment tab
  • Select New and set the "PATH" variable to the location of ndds java libraries.
    If you want to use an XML QoS configuration file, then the working directory needs to be set as indicated below
  • Select the (x)= Arguments tab
  • Under working directory, select Other: and then click on File System…
  • Browse to <your workspace>/<your project name>/src
    If you are using a release prior to 4.4d or you do not want to use an XML file, then the above 3 steps can be skipped
    Click Apply and Run. You will see the application's output in the Console tab.
Programming Language:

Comments

How to run rtiddsgen from within Eclipse:

Windows:

  1. Open the Run > External Tools > External Tools Configurations... dialog
  2. Select "Program" and click the New icon (white page with gold +)
  3. Enter a name (like "rtiddsgen repl no ex")
  4. From the Main tab
    1. Set the location to "<RTI Home Directory>\scripts\rtiddsgen.bat"
    2. Set the Working Directory to "${project_loc}\src"
    3. Set the Aguments list to as desired, a good starting point is: -language java -ppDisable -replace -d ${project_loc}\src -inputIdl ${selected_resource_loc}
  5. From the Common tab, consider checking the 'Display in favorites menu > External Tools' and the 'Launch in background' checkboxes

MacOS:

  1. As above for Windows, with the following changes
    1. Where necessary, change the path markers from \ to /, and remove the ".bat" from rtiddsgen
    2. In the Environment tab, click New... and enter "XALANHOME" and its location in the presented dialog

Once the tool is configured, you can clone it and change the name/arguments list to get different behavior:

  • rtiddsgen:        -language java -ppDisable -d ${project_loc}\src -inputIdl ${selected_resource_loc}
  • rtiddsgen ex:    -language java -ppDisable -example x64Win64jdk -d ${project_loc}\src -inputIdl ${selected_resource_loc}
  • etc

To run the script, click on an IDL file in a project, and select the desired external tool configuration. The code will be generated into that project's src directory, including any packages (from IDL module declarations).