### Building a JReport Enterprise Server WAR manually (deprecated)

This section introduces a method that has been used in earlier versions. If using this method, you will have to specify the JReport Enterprise Server installation root as the reporthome unless you make the WAR be a self-contained solution.

This section takes creating a WAR file on UNIX for example. The instruction is applicable to both UNIX and Windows platforms. However, the paths for Windows should use the Windows format, for example, `C:\JReport\Server`, while paths for UNIX should use the UNIX format, for example, `/opt/JReport/Server`.

It is assumed that JReport Enterprise Server has been installed to `/opt/JReport/Server`.

Take the following steps to build a JReport Enterprise Server WAR manually:

1. Create a new directory jreport in the JReport Enterprise Server installation root: `/opt/JReport/Server/``jreport`.
2. Create a sub directory WEB-INF in jreport: `/opt/JReport/Server/jreport/WEB-INF`.
3. Create a web.xml file in the WEB-INF directory as follows:

       <?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems,
       Inc.//DTD Web Application 2.3//EN"
       "http://java.sun.com/dtd/web-app_2_3.dtd">

       <web-app>
       <listener>
       <listener-class>jet.server.servlets.JRServerContextListener</listener-class>
       </listener>

       <servlet>
       <servlet-name>jrserver</servlet-name>
       <servlet-class>jet.server.servlets.JRServlet</servlet-class>
       </servlet>

       <servlet>
       <servlet-name>sendfile</servlet-name>
       <servlet-class>jet.server.servlets.SendFileServlet</servlet-class>
       </servlet>

       <servlet>
       <servlet-name>dhtml</servlet-name>
       <servlet-class>jet.web.dhtml.DHTMLlet</servlet-class>
       </servlet>

       <servlet>
       <servlet-name>help</servlet-name>
       <servlet-class>jet.web.dhtml.JHelplet</servlet-class>
       </servlet>

       <servlet-mapping>
       <servlet-name>jrserver</servlet-name>
       <url-pattern>/jrserver/*</url-pattern>
       </servlet-mapping>

       <servlet-mapping>
       <servlet-name>sendfile</servlet-name>
       <url-pattern>/sendfile/*</url-pattern>
       </servlet-mapping>

       <servlet-mapping>
       <servlet-name>dhtml</servlet-name>
       <url-pattern>/dhtml/*</url-pattern>
       </servlet-mapping>

       <servlet-mapping>
       <servlet-name>help</servlet-name>
       <url-pattern>/help/*</url-pattern>
       </servlet-mapping>

       </web-app>

4. Create a directory lib in the `jreport/WEB-INF` directory:

   `mkdir lib`

5. Create a directory pages in the `jreport/WEB-INF/lib` directory:

   `mkdir lib/pages`

6. Copy all of the files in `/opt/JReport/Server/lib/pages` to the `jreport/WEB-INF/lib/pages` directory:

   `cp /opt/JReport/Server/lib/pages/* lib/pages`

7. Create a jar file to include the resources folder which is located in `/opt/JReport/Server` and name it languages.jar. For example, run the following command:

   `jar -cvf languages.jar resources`

   Then put the languages.jar in `/opt/JReport/Server/lib`.

8. Copy the following jar files from `/opt/JReport/Server/lib` to the `jreport/WEB-INF/lib` directory: commons-codec-1.2.jar, hsqldb.jar, jai_codec.jar, jai_core.jar, JREngine.jar, JRESServlets.jar, JRWebDesign.jar, languages.jar, log4j-1.2.8.jar, sac.jar, tar.jar, xercesImpl.jar, xml-apis.jar.

   If you want to export reports to the following formats, you should copy the corresponding jar to the `jreport/WEB-INF/lib` directory:

   - To e-mail or use the e-mail Notification function, copy activation-1.1.jar and mail-1.4.jar.
   - To FTP, copy commons-net-ftp-2.0.0.jar.
   - To PDF and DHTML, copy itext.jar.
   - To Excel, copy poiHSSF_151.jar.
9. Copy the index.htm file and the admin, dhtmljsp, images, javascript, jinfonet, skin, and style folders from `/opt/JReport/Server/public_html` to the `/opt/JReport/Server/jreport` directory:

   `cp -r /opt/JReport/Server/public_html/* /opt/JReport/Server/jreport`

   Notes:

   - The jsp files within the admin folder are used by the JReport Administration pages. Those within the dhtmljsp folder are used when viewing reports in the DHTML format.
   - If you copy index.htm and these folders mentioned above to a sub folder in `/opt/JReport/Server/jreport`, for example, `/opt/JReport/Server/jreport/sub`, to view reports in DHTML format, you need:
     - Modify the server.properties file:

       `web.skin.dir=/jreport/sub/skin`

     - Uncomment the following lines in dhtml.jsp in the dhtmljsp folder and make it adapt to the environment as follows:

       `dhtmlConfig.setDHTMLContextPath(SessionID,"http://localhost:8080/jreport/sub");
       dhtmlConfig.setDHTMLJspUrl(SessionID,"/jreport/sub/dhtmljsp/");
       dhtmlConfig.setDHTMLServletUrl(SessionID, RptSetId, "/jreport/dhtml");`

     - In the step 10, edit the index.htm file like this:

       `<FRAME name="ind" src="/jreport/sub/jinfonet/index.jsp" frameborder="0">`

     Then go to step 11.

10. Edit the index.htm file and add the context path `/jreport` to the src tag. Note that the path separator character is the Unix style "/" when referencing JSP. The result should be as follows:

    `<FRAME name="ind" src="/jreport/jinfonet/index.jsp" frameborder="0">`

11. Using the following command to create a WAR file named jreport.war:

    `jar -cvf jreport.war index.htm admin dhtmljsp images javascript jinfonet skin style WEB-INF`

    Note: The jar utility is in the Java home bin directory. If it is not on your path you must call jar with the entire path, for example, `/opt/j2sdk1.4.2_07/bin/jar.exe`.

#### To make the WAR be a self-contained solution

To make the WAR include a self-contained JReport Enterprise Server, except for the above procedure, you need create jrenv.jar and then put it in the `jreport/WEB-INF/lib` directory before creating the WAR.

Use either way to create the jrenv.jar:

- By the makewar.bat/makewar.sh tool
  For example: run the command `makewar jrenv.jar`
- Creating manually
  Make sure all necessary contents are included and then use a proper tool to package them into a jar file.

See also Building a WAR/EAR file to include a self-contained JReport Enterprise Server for details about the structure of the jrenv.jar.