# Run Export Out of Process

The `HtmlTest.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 `HtmlExport` class.

       HtmlExport objHtmlExport = new HtmlExport();

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

       objHtmlExport.setIniFileName(iniFile);

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

       HtmlOptionInfo
       HtmlTemplateInfo
       HtmlTOCOptionInfo
       StyleMapping
       HtmlHeadingInfo

   Set the classes to the current `HtmlExport` 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.

       objHtmlExport.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
       objHtmlExport.setInputSource(inFile);
       //set the input source as stream
       inf = new File(inFile);
       fis = newFileInputStream(inf);
       objHtmlExport.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.

       objHtmlExport.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.

       objHtmlExport.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.

       objHtmlExport.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`.

        objHtmlExport.endOOPSession(FALSE);

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

        objHtmlExport.shutdownExport();

_FT_HTML5_bannerTitle.htm