Overview
When you need secondary development for FineReport through Java class code to implement certain functions, it is usually necessary to compile Java files to generate Class files. Class files are required in applications such as program data sources, program reports, custom functions, custom background export, and custom printing. So, what preparations are needed for compiling Java files during second development? This document will introduce details.
Preparing the Compilation Environment
Project Preparation
Before compiling the program, you need to create a Java project environment and prepare a Java editor (for example, Eclipse or IntelliJ IDEA). If there is no existing Java project environment, you can create a Java project through the editor (for example, the Ideal editor), as shown in the following figure.

Importing JAR Packages
Before compiling the program, you need to import some necessary JAR packages into the project, which is mainly divided into two categories: the FineReport project JAR package and the third-party JAR package required for compiling the program. Among them, the FineReport project JAR package must be imported. The third-party JAR package can be added according to the actual scenario requirements. It does not need to be added if there are no relevant requirements.
FineReport Project JAR Package
The FineReport project JAR package that need to be imported includes:
All packages under your report project %FR_HOME%/lib directory
All packages under the %FR_HOME%/server/lib directory
All packages under the %FR_Home%/webapps/webroot/WEB-INF/lib directory
In addition, JDK's tools.jar needs to be imported.
Use the Idea editor to import the above necessary packages for creating a project JavaIdea, as shown in the following figure.
Importing the third-party JAR Package
If you need to import third-party JAR packages, follow the steps below. If you don't need to import, ignore the steps.
Two main ways are available to import the third-party JAR package.
1. After downloading the third-party JAR package, place it under the %FR_HOME%\webapps\webroot\WEB-INF\lib directory, which is the same directory as the directory of fine-decision-10.0.jar provided by FineReport. Import the third-party JAR package together with the FineReport project JAR package.
2. Download and place the third-party package under a custom directory, and then import the package. Use the Idea editor to import the third-party JAR package slf4j-simple-1.7.25 into the JavaIdea project, as shown in the following figure.
Compiling a Java File
After preparing the compilation environment, you can write and compile a Java file.
Writing a Java File
Create a Java file, and write Java codes in the editor. Use the Idea editor to create and write the custom function StringImage, as shown in the following figure.
Compiling a Java File
After completing a Java file, compile it in the compiler, and no error is reported. After successful compilation, a Class file will be generated in the corresponding project.
After the custom function StringImage is successfully compiled, the StringImage.class file will be generated in the corresponding project's compilation directory, as shown in the following figure.