Debugging a Macro Using an IDE

You can debug a Simcenter STAR-CCM+ macro using a special command-line option and an Integrated Development Environment (IDE) program.

There are several IDEs available for free download including the following:

The instructions below are for debugging a macro using NetBeans. It is necessary to use version 12.6 or later. Similar techniques can be used for other IDEs.

The process for debugging a macro involves the following steps:

  1. Loading the macro in the IDE
  2. Running Simcenter STAR-CCM+ in debugging mode
  3. Stepping through the macro

Loading the Macro in the IDE

NetBeans requires the macro to be in a directory structure <ProjectFolder>/<SourceFolder>/<Macro>.java, so you must organize the macro and any input files to be in the appropriate locations before starting.

  1. In NetBeans, select File > New Project.
  2. In the New Project wizard, select Java Project with Existing Sources and click Next.


  3. In the Name and Location panel specify a name for your project in Project Name, provide the location of your project directory in Project Folder, and click Next.


  4. In the Existing Sources panel, click the Add Directory button for the Source Package Folders, add the source directory that you created earlier and click Next.


  5. In the Includes panel, ensure that the required macro is highlighted.


  6. Click Finish to create the project.

The next step is to add the Simcenter STAR-CCM+ JAR files to the project so that the IDE can interpret the Simcenter STAR-CCM+ Java classes. Add the JAR files that are held in the ext/ directory that is created as part of the installation of Simcenter STAR-CCM+.

  1. In the Projects panel in NetBeans, right-click Libraries and select Add JAR/Folder.


  2. In the Simcenter STAR-CCM+ installation directory, select every JAR file in the ext/ directory.

    On Linux and Windows, this directory is located in:

    [INSTALLDIR]/star/lib/java/platform/modules/ext/

    The error symbols disappear from the macro.



    You are now ready to start Simcenter STAR-CCM+ in debugging mode.

Running Simcenter STAR-CCM+ in Debugging Mode

Simcenter STAR-CCM+ can pass messages directly to the Java Virtual Machine on which the client runs. You can use this function to attach NetBeans to the instance of Simcenter STAR-CCM+ through a specified port. In the examples below the port number 8765 is used but you can use any unused port number.

  1. Do one of the following:
    • On Windows, in a command prompt, enter the following command on a single line:

      <InstallationDirectory>\star\bin\starccm+ -jvmargs "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8765"

    • On Linux, in a terminal window, enter the following command on a single line:

      <InstallationDirectory>/star/bin/starccm+ -jvmargs '-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8765'

    Simcenter STAR-CCM+ opens.

Now attach the IDE to Simcenter STAR-CCM+ through the port:

  1. In NetBeans, select Debug > Attach Debugger, set Host to localhost, specify the port number from the command line above, and click OK.


    You are now ready to run the macro in debugging mode.

The macro executes to the specified breakpoint. You can use the IDEs stepping tools to work through each command from this point.

Stepping Through the Macro

Connecting Simcenter STAR-CCM+ to an IDE lets you execute a macro up to any line and step through individual commands to understand each. Once the IDE is attached to Simcenter STAR-CCM+, you can create one or more breakpoints in the macro before running.

To step through the macro, do the following:

  1. In NetBeans, place a breakpoint at the start of your macro by clicking the line number.


  2. In Simcenter STAR-CCM+, load or create a case as necessary.
  3. In Simcenter STAR-CCM+, run the macro.