Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin
Wiki Markup
{scrollbar}

----
In this section you will discover the different configuration files, their loading order and why they have been introduced. Talking about all the configuration keys here is far beyond the scope of this article, only a few will be presented to cover JFreeReport core configuration.
JFreeReport is composed of several files which define configuration properties, each of them can be overriden by setting them as environment properties or using a special file made to help users and simplify the configuration process. This file has to be nammed {{jfreereport.properties}} and must be at the root of your classpath. It must be reachable for the following java code :
{code}

...

In this section you will discover the different configuration files, their loading order and why they have been introduced. Talking about all the configuration keys here is far beyond the scope of this article, only a few will be presented to cover JFreeReport core configuration.
JFreeReport is composed of several files which define configuration properties, each of them can be overriden by setting them as environment properties or using a special file made to help users and simplify the configuration process. This file has to be nammed jfreereport.properties and must be at the root of your classpath. It must be reachable for the following java code :

Code Block
getClass().getResource("/jfreereport.properties");
{code}

Properties

...

files

...

(

...

*.properties

...

)

...

are

...

simply

...

text

...

files

...

that

...

expose

...

key=value

...

statements

...

where

...

lines

...

starting

...

with

...

the

...

sharp

...

character

...

'#'

...

are

...

skipped.

...

If

...

you

...

need

...

more

...

accurate

...

informations,

...

have

...

a

...

look

...

to

...

the

...

Properties

...

class

...

javadoc.

...


As

...

I

...

said,

...

JFreeReport

...

is

...

composed

...

of

...

several

...

configuration

...

files

...

so

...

I

...

will

...

show

...

you

...

the

...

order

...

they

...

get

...

loaded.

...

The

...

last

...

properties

...

loaded

...

override

...

the

...

ones

...

declared

...

previously:

...

  1. The

...

  1. main

...

  1. configuration

...

  1. file:

...

  1. /org/jfree/report/jfreereport.properties

...

  1. The

...

  1. configuration

...

  1. file

...

  1. of

...

  1. JFreeReport

...

  1. extenstions

...

  1. subproject:

...

  1. /org/jfree/report/ext/jfreereport-ext.properties

...

  1. Each

...

  1. module

...

  1. configuration

...

  1. file

...

  1. using

...

  1. the

...

  1. following

...

  1. pattern:

...

  1. <path/to/module>

...

  1. /configuration.properties

...

  1. The

...

  1. user

...

  1. configuration

...

  1. file

...

  1. we

...

  1. talked

...

  1. earlier:

...

  1. /jfreereport.properties

...

  1. Every

...

  1. system

...

  1. properties

...

  1. are

...

  1. collected

...

  1. during

...

  1. the

...

  1. initialization

...

  1. time.

...

  1. It

...

  1. gives

...

  1. an

...

  1. easy

...

  1. way

...

  1. to

...

  1. configure

...

  1. properties

...

  1. without

...

  1. editing

...

  1. a

...

  1. file,

...

  1. generaly

...

  1. for

...

  1. test

...

  1. purposes.

...


  1. Using

...

  1. the

...

  1. java

...

  1. command

...

  1. line:

...

  1. Code Block

...

  1. 
    java -D<property>=<value> ...
    

...

  1. Using

...

  1. the

...

  1. bash

...

  1. interpreter:

...

  1. Code Block

...

  1. 
    # On Windows environments
    $> set <property>=<value>
    # On Unix environments
    $> export <property>=<value>
    # Then run your command
    
    # On Unix environments you can also define per command system properties
    $> <property>=<value> yourCommand
    

...

  1. Using

...

  1. the

...

  1. java

...

  1. API:

...

  1. Code Block

...

  1. 
    System.setProperty("somekey", "somevalue");
    

...

  1. Before JFreeReport has boot,

...

  1. you

...

  1. can

...

  1. eventualy

...

  1. define

...

  1. manual

...

  1. user

...

  1. properties

...

  1. using

...

  1. the

...

  1. following

...

  1. code:

...

  1. Code Block

...

  1. 
    JFreeReportBoot.getInstance().setConfigProperty("somekey", "somevalue");
    ...
    JFreeReportBoot.getInstance().start();  // boot is done later in your program
    

...

  1. Per report user configuration properties which can be setted using the following code:
    Code Block
    
    report.getReportConfiguration().setConfigProperty("somekey", "somevalue");
    

...

  1. This

...

  1. kind

...

  1. of

...

  1. configuration

...

  1. can

...

  1. also

...

  1. be

...

  1. feeded

...

  1. from

...

  1. the

...

  1. XML

...

  1. report

...

  1. definition:

...

  1. Code Block
    
    // Simple XML definition
    <report>
    ...
      

...

  1. <configuration>
        

...

  1. <!-- <property name="property">value</property> -->

...

  1. 
        

...

  1. <property name="org.jfree.report.modules.output.pageable.pdf.Encoding">Identity-H</property>
        

...

  1. <property name="org.jfree.report.modules.output.pageable.pdf.EmbedFonts">true</property>
        

...

  1. <property name="org.jfree.report.targets.table.TableWriter.SheetNameFunction">sheetNameExpression</property>
        ...
      </configuration>
    ...
    </report>
    
    // Extended XML defintion
    <report-definition>
    ...
      <report-config>
      ...
        <configuration>
          <property name="org.jfree.report.modules.output.pageable.pdf.Author">Darkwing Duck</property>
          <property name="org.jfree.report.modules.output.pageable.pdf.Encoding">iso-8859-15</property>
          ...
        </configuration>
      ...
      </

...

  1. report-config>
      ...
    </report-definition>
    

We recommand the use if the file nammed jfreereport.properties because it is usualy easier to maintain as it centralizes the user configuration in a known place and should be more resisting to migrations. A migration tool could be envisaged to verify a single file not to verify all your code.