A key feature of the Wolfram Workbench is its ability to run and debug code as you are developing it. It allows you to use the Mathematica notebook front end to enter commands that execute your code.

If you just want to execute code from Mathematica source files in your project, you can do this by opening a notebook from the project, and loading the code into Mathematica. For example, if you created a basic project Test, you can open the notebook file, Test.nb, and then load and use Test.m.

When the Workbench runs in this mode it is not strongly connected to Mathematica, so that if you modify your code you will have to manually load it. In addition, you cannot do debugging. These are described in the rest of this section, but if simple running of your code works for you then you do not need to read any further.

Run and Debug with Mathematica

To debug your code using the front end, you should select a notebook in your project and right-click. This should bring up a popup menu customized for notebooks; it contains a Debug As choice.

This lets you launch Mathematica in a debug mode that gives you all the features of a source level debugger. There is also a Run As choice that will launch Mathematica but does not let you debug it. For running via the notebook front end this is not so useful, since you can just open the notebook and load code.

For either run or debug the notebook will be opened in the front end, and the Mathematica kernel (the default for the front end) will be initialized by the Workbench. Note how the Test.m file that was created has been loaded into the front end as shown in output in the Console view.

New Project Wizard

Executing in Mathematica

Now you can execute your code in Mathematica. For example, you can call the function that was defined in Test.m. Type fun[10] into the notebook and evaluate this in the normal way for Mathematica (select the cell bracket, and press Shift+Enter). The result of this computation appears in the notebook.

New Project Wizard

Launching Again

Once you have launched Mathematica in a run or debug mode from a particular notebook, it is easy to repeat the process. From the toolbar, use the button debug for launching in debug mode and debug for launching in run mode.

This is also possible from the menu bar by choosing Run > Run... or Run > Debug... and selecting the Wolfram Workbench item.