Using Programs

This topic contains key information including:


  • compiling programs
  • extracting and inserting JPO code
  • passing arguments
  • Java options

The sections that follow include some basic MQL syntax for the above functionality.

This task shows you how to:

Compile command

This is useful for bulk compiling and testing for compile errors after an iterative change to the JPO source.

  • To force compilation before invoking a JPO method, use compile program:

    compile program PATTERN [force] [update] [COMPILER_FLAGS];

    When a JPO is compiled or executed, any other JPOs which are called by that JPO or call that JPO must be available in their most recent version. The compile command includes an update option which will update the requested JPO's dependencies on other JPOs that may have been added, deleted, or modified.

Execute command

  • To run a program, use the execute program command:

    exec program PROGRAM_NAME [-method METHOD_NAME] [ARGS] [-construct ARG];

    where:

    ARGS is zero or more space-delimited strings.

    The -construct clause is used to pass arguments to the constructor. ARG is a single string. If more than one argument needs to be passed to the constructor, the -construct clause can be repeated as many times as necessary on a single command.

Extract command

Extracting the Java source in the form of a file out to a directory is useful for working in an IDE.

While in the IDE a user can edit, compile, and debug code. The extract program command processes any special macros and generates a file containing the Java source of the JPO. If no source directory is given, the system uses ENOVIA_INSTALL/java/custom (which is added to MX_CLASSPATH automatically by the install program).

extract program PATTERN [source DIRECTORY] [demangle]

In order to use the extract feature, the JPO name must follow the Java language naming convention (i.e., no spaces, special characters, etc.). Only alphanumeric printable characters as well as '.' and '_' are allowed in class names in the JPO.

Insert command

After testing and modifying Java source in an IDE, it is necessary to insert the code back into JPOs in the database. The insert program command regenerates special macros in the Java source as it is placed back into a JPO (reverse name-mangling). If the JPO does not exist, the insert command creates it automatically.

  • To insert a program:

    insert program FILENAME | DIRECTORY;

    For example:

    insert program matrix/java/custom/testjpo_mxJPO.java
    

    OR

    insert program matrix/java/custom/
    

    The later will insert all the .java files in the specified directory.