Can anyone please tell me a way to execute the jasper report through java , as well as please tell me which jars are needed to be used?
Also please tell hoe to pass prameters and as well as how to retrieve which parameters are required through java program ,in order to run jasper report.
Hi all ,
I have found a solution to the query on my own, thanks augarte for the explanation regarding the implementation in java that helped,but the real problem was that retrieving the parameters from the jrxml .It is possible to do so.
I found a way for that by parsing the xml and then extracting the tags with parameter and retrieving the attribute name and class keeping in mind the check attribut isForPrompting is blank or not present for the parameters , In this way I got the Hashmap of all the parameters with their types and I put that in the parameterMap and hence fulfilling the parameters in the jrxml dynamically .Solves the purpose for me.
The jars need to be included are-
8.poi-x.x.jar(for excel export)
Hope that this is helpful
The code depends on the datasource you want to use for generating the report, this one is an example that shows how to create a pdf file having a xml datasource and a jrxml file:
In thas case you need to get the connection to the database first. This link can help you: http://www.roseindia.net/tutorial/java/jdbc/jdbcdrivermanager.html
Then, the code should be very similar to the one I have posted. The only modification is the call to fillReport function:
JasperPrint Prn = JasperFillManager.fillReport (Rep, new HashMap (), Con);
As you can see the only modification is in the last parameter "Con" (java.sql.Conneciton type), which is the connection to your database, and you can get it in the link I have put above.
Hope this helps.
In the report Properties there is an option "Language" (check the attachment). I think your poblem is that you have selected "Groovy" instead of Java. Try changing this property and setting it as Java.
This might solve your problem.