System.setProperty("sree.home", "{path to registry}");
To do this from the command line (for example, when running a program named “ProgramName”), use the following syntax:
java -Dsree.home="{path to registry}" ProgramName
Importing Report Templates
To use a report template in a Java program, the first step is to create a ReportSheet object from the template file. The Builder class in the inetsoft.report.io package handles this.
Builder builder = Builder.getBuilder(Builder.TEMPLATE,
new FileInputStream(“report1.srt”));
ReportSheet report = builder.read(“.”);
If the template is not stored in the correct format, an Exception will be returned and it should be properly handled.
The argument to the Builder.read() is a directory which is used to calculate the image paths if relative file paths are used in the template to specify the image file locations. If no image is used in the report, then the directory can be passed with any value.
Report templates can be loaded from a remote site through a URL. To do this, simply get an input stream object from a URL and the builder will read the template information from the remote server pointed to by the URL:
URL url = new URL(“http://…”);
Builder builder = Builder.getBuilder(Builder.TEMPLATE, url.openStream());
ReportSheet report = builder.read(".");
The directory passed into the read() call is ignored in this case, so the template cannot use any local files for image elements.
Perhaps the most flexible way to import a template file is by loading the file in as a resource file. This allows the template files to be packaged as part of the application JAR file or together in the class file directory tree. Once the CLASSPATH is properly setup, resource files can be located by the Java class loader in the same way as other class files. This enables the templates to be used independent of the location of the installation.
InputStream input =
getClass().getResourceAsStream("/templates/report1.srt");
Builder builder =
Builder.getBuilder(Builder.TEMPLATE, input);
ReportSheet report = builder.read(".");