I wrote some Java class, created jar file. I want to add it to JasperReports Server. When I determine the path to my jar file, using Tools -> Preferences -> Classpath menu in my iReport, it works correctly. But it doesn't work, when I take access to JR Server from another host.
What I must to do, to make this jar file available on this JR Server, from anywhere?
Option 1 - If you want to use your Jar in a several reports.
You should "Add Jar" (as it called in iReport repository manager) to some folder in the Jasper Server folder tree. Then "Add reference" to this resource in Resources section of you specific report.
Option2 - You need a jar in a specifc report.
Use "Add Jar" option in a resources section of specific report.
Worked perfectly on JasperServer 4.7
Add the jar as a resource of the report (if it's one time use) or add it to some path in Jasper Report Server and add a reference to it as Alex suggested.
I'd suggest you to create some folders in Jasper Server (via web interface or iReport) and put all commonly used filed there (be sure to manage correctly the permissions ROLE_USER should have access to the file but you can remove it from the folder so it's not listed).
Then use references on the reports that need those. For example, I use it for the report logo and some helper Java classes.
Edit as @NormTatlock asked more details on how to do it:
Create your Java package my.sample.package for example:
public class MyClass extends JRDefaultScriptlet ...
Compile it and upload the jar as a resource using its full name (e.g. my.sample.package.jar) or upload it to another folder and create a reference to it in the resources folder of the report.
Edit the report and set the Scriptlet Class property to:
my.sample.package.MyClass
Or set the property in the XML tag jasperreports (the root tag) as:
scriptletClass="my.sample.package.MyClass"
Use the scriptlet in your report like this:
$P{REPORT_SCRIPTLET}.myMethod(myParam1, myParam2)
Mind the return type of the methods and so on.
Hope it helps. Have fun!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With