Launching a Jython Module

Jython launch configurations are very similar to Java launch configurations, because running Jython is simply running a Java application (the Jython interpreter). The Jython plug-in tries to fill in as much attributes of a Jython launch configuration as possible to minimize the configuration overhead. If Jython projects are configured properly, no extra steps are required to run modules.

Follow these steps to run a module:

  1. Select a module, either by selecting the file in the Navigator view or by bringing the editor on the file to the front. In this example, we select a file "b.py".
  2. Select Run>Run... from the menu bar or Run... from the tool bar to open the launch configuration dialog.

  3. On the left in the dialog, the list of configurations includes an item labeled "Jython". Select it.

  4. Press "New". A new Jython launch configuration appears. The field labeled "Module" includes the selected module. By pressing "Variables..." you can select a variable. Only ${resource_name} is valid. By using that variable, the launch configuration can be used for different modules.

  5. Enter a name for the configuration in the field labeled "Name". Press "Apply" The dialog will look like shown below.

    The "Jython Main" tab also includes a field labeled "Module arguments". Enter the arguments of the module here. For instance, arguments for a unit test module can be entered here to run selected test cases.

  6. Select the second tab, labeled "Java Main". It displays a field to enter the Java class that is run when the Jython launch configuration is run. By default, the field's contents is set to "org.python.util.jython". It should not be changed, unless you are an experienced Jython developer who developed his/her own class to start a Jython executable. In that case, your custom class should be entered here and you should make sure that the jar that includes the class is listed on the class path (see later).

  7. Select the third tab, labeled "Arguments". It displays several fields that are filled in automatically.

    The first field, labeled "Program arguments" shows the argument string as it will be passed to the main Java class. The contents of the field is recomputed whenever the fields on the "Jython Main" tab change. The field is read-only. It serves the purpose of checking that the correct argument string is passed.

    The second field, labeled "VM arguments", shows the arguments that will be passed to the Java virtual machine. The field is filled in automatically. It contains -D options that define names that should be known by the Jython interpreter. "python.home" is bound to the Jython installation folder and "python.path" is bound to the library folder on the Jython installation, as set in the preferences (see Getting started).

    The working directory section on the "Arguments" tab specifies the parent folder of the selected file. It is specified relative to the project in which the file resides.

  8. Select the "JRE" tab. It specifies the virtual machine that should be used to run Jython. Most of the time, the default virtual machine is ok.

  9. Select the "Classpath" tab. It specifies the jars that should be on the class path when a module is run.

    The Jython jar, as specified in the preferences (see Getting started), is added to the list of "User Entries" automatically. It should always be included in the list, otherwise it is impossible to run Jython. Jars that are listed as required jars for the project in which the file resides (see Creating a Jython project) are also added to the list automatically. In this example, ConsoleWriter.jar is specified on the project in which the example file "b.py" resides.

    The "Bootstrap Entries" list includes all jars required to run a Java application. Under normal circumstances, the default list is not changed.

  10. The "Source" tab lists where to find source files in case they are necessary for showing code (for instance during debugging). By default, all jars on the class path are listed, whether they contain source code or not.

  11. The "Environment" tab (not shown here) lists the environment variables that will be passed into the launch configuration when it is executed.
  12. The "Common" tab (not shown here) is the standard Common tab as found in all launch configurations. The default settings are fine in most situations.
  13. Press the "Run" button to launch the selected module.

Instead of opening the launch configuration dialog, you can also use the Jython launch shortcut.

  1. Select a module, either by selecting the file in the Navigator view or by bringing the editor on the file to the front. In this example, we select a file "b.py".
  2. Select Run>RunAs>Jython from the menu bar or Run As>Jython from the tool bar.

  3. The plug-in deducts all required data to run the module and launches it.
  4. The launch shortcut is added to the menu, so that you can use the shortcut over and over again.

  5. When you choose Run>RunAs>Jython from the menu bar or Run As>Jython from the tool bar, the plug-in will always try to reuse a launch shortcut for the multiple shortcuts for the same launch configuration. When more than one launch configuration for the selected module is available, as in this example:

    you will be prompted to select one: