# Run Export Out of Process

The `XmlTest.java` sample program demonstrates how to run Export out of process.

To convert files out of process in the Java API

1. If required, set parameters for the out-of-process conversion in the `formats_e.ini` file. See Configure Out-of-Process Conversions.

2. Create an instance of the `XmlExport` class.

       XmlExport objXmlExport = new XmlExport();

3. If you are using a template file to set the conversion options, call the `setIniFileName` method.

       objXmlExport.setIniFileName(iniFile);

4. If you are using the API to set the conversion options, create instances of the following classes:

       XmlTemplateInfo
       XmlOptionInfo
       XmlTOCOptionInfo
       StyleMapping
       XmlHeadingInfo

   Set the classes to the current `XmlExport` object using the appropriate set methods. If you do not set the classes before calling the `startOOPSession` method, default values are used.

5. Set the location of the Export libraries by calling the `setExportDirectory` method. These are normally in the directory `install\OS\bin`, where `install` is the path name of the Export installation directory and `OS` is the name of the operating system.

       objXmlExport.setExportDirectory(exportDir);

6. Optionally, set the input source as either a file or stream by calling the `setInputSource` method.

       //set the input source as file
       objXmlExport.setInputSource(inFile);
       //set the input source as stream
       inf = new File(inFile);
       fis = newFileInputStream(inf);
       objXmlExport.setInputSource(fis);

7. Set up an out-of-process session by calling the `startOOPSession` method. This initializes the out-of-process session, creates a Servant process, establishes a communication channel between the application thread and the Servant, and sends the data to the Servant.

       objXmlExport.startOOPSession();

8. Convert the input and generate the output files by calling the `convertTo` method. You cannot use the `convert` methods that set the input source because the input source must be set before the out-of-process session is initialized. The `convertTo` method can only be called once in a single out-of-process session.

       objXmlExport.convertTo(outFile);

9. Terminate the out-of-process session by calling the `endOOPSession` method. The Servant ends the current conversion session, and releases the source data and session resources.

       objXmlExport.endOOPSession(TRUE);

10. Repeat Step 3 through Step 9 for additional files.

11. After all files are converted, terminate the out-of-process session and the Servant process by calling `endOOPSession` and setting the Boolean to `FALSE`.

        objXmlExport.endOOPSession(FALSE);

12. Terminate the Export session and free allocated system resources by calling the `shutdownExport()` method.

        m_objExport.shutdownExport();

_FT_HTML5_bannerTitle.htm