Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9018475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:32:10+00:00 2026-06-16T04:32:10+00:00

I have some problems with JasperReport. I’ve generated a *.jrxml File through iReport. There

  • 0

I have some problems with JasperReport. I’ve generated a *.jrxml File through iReport.
There I’ve definded some fields. Now i want to set these fields in my Java-Application, but it didn’t work.

My Code looks like

JasperReport report;
    JasperPrint print;

    HashMap<String, Object> parameters = new HashMap<String, Object>();

    parameters.put("logoPath", "\\logo.jpg");
    parameters.put("companyName", "Company Name");

    try {
        report = JasperCompileManager
                .compileReport("JRXML\\Template.jrxml");

        for (JRField field : report.getFields()) {
            System.out.println(field.getName() + "|"
                    + field.getValueClassName());
        }

        print = JasperFillManager.fillReport(report, parameters,
                new JREmptyDataSource());
        JasperExportManager.exportReportToPdfFile(print,
                "\\temp\\Example.pdf");

        JasperViewer.viewReport(print);

    } catch (Exception e) {
        // TODO Auto-generated catch block
        Logger.getLogger(Example1.class.getName()).log(Level.ALL,
                e.getLocalizedMessage());

        e.printStackTrace();
    }

The fields are given in the *.jrxml file.

Thanks for your help

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T04:32:11+00:00Added an answer on June 16, 2026 at 4:32 am

    You are confusing parameters with fields. A paramater is defined as <parameter name="companyName" class="java.lang.String" isForPrompting="false">, while a field is defined as <field name="companyName" class="java.lang.String"/>. Convert company name to parameter in your jrxml and it should work.

    From this tutorial

    Parameters

    Parameters are object references that are passed-in to the report
    filling operations. They are very useful for passing to the report
    engine data that it can not normally find in its data source.

    Fields

    Report fields represent the only way to map data from the data source
    into the report generating routines. When the data source of the
    report is a ResultSet, all fields must map to corresponding columns in
    the ResultSet object. That is, they must have the same name as the
    columns they map and a compatible type.

    ORIGINAL ANSWER:

    Use a FileResolver for logo.jpg, which Jasper will use to resolve files locations.

    FileResolver fileResolver = new FileResolver() {
    @Override
    public File resolveFile(String fileName) {
     URI uri = null;
     try {
    uri = new URI(this.getClass().getResource("/" + fileName).getPath());
     } catch (URISyntaxException e) {
     }
    return new File(uri.getPath());
    }
    };
    
    HashMap<String, Object> parameters = new HashMap<String, Object>();
    
    parameters.put("logoPath", "\\logo.jpg");
    parameters.put("companyName", "Company Name");
    parameters.put("REPORT_FILE_RESOLVER", fileResolver);
    ...
    print = JasperFillManager.fillReport(report, parameters,
    new JREmptyDataSource());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some problems sending mails through SMTP using Spring's MailSender interface and the
I have some troubles with JasperReports. I generated a formular with iReport including two
I have some problems with the URL dispatching. There're my rules: urlpatterns += patterns('proxy.views',
I have some problems using Code Igniter and I feel there is something I
I have some problems with authorization. I don't want to use Spring Security, just
I have some problems with IE 9 and CSS. I want to make a
I have some problems. I want to transfer messages. I use context.sendBroadcast to send
I have some problems with custom validator constraints. I want to validate a field
I have some problems with an rpm spec file that is listing the same
I have some problems with my htaccess... I want to have my url's like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.