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!
Related
How can I generate the JMeter HTML/dashboard report without having always generated and saved the sbadmin2 folder that is needed for the bootstrap layout? Also, where does the import of the results into the index.html file happen?
The feature you're asking for does not exist, I've created this enhancement request for it:
https://bz.apache.org/bugzilla/show_bug.cgi?id=61458
It should not be to hard to add if it's needed.
I took the java implementation of the Factual API (reference http://developer.factual.com/) and made a JAR file for factual. I did this by opening a new project in eclipse with the factual java files and then exporting to a new jar file.
I put that jar file in my coldfusion installation's /WEB-INF/lib/ folder.
After restarting Coldfusion, I tried to create a new cfobject like so
<cfscript>
// Initialize the Java class.
factualClass=CreateObject("java", "src.main.java.com.factual.driver.Factual");
</cfscript>
I get an error indicating that it cannot find the Factual class.
Can anybody give me some guidance?
(Summary from comments)
It sounds like you may be exporting the source files ie *.java rather than the compiled class files, ie *.class. In the Jar Export wizard, be sure to select the "Export generated class files and resources" option. (To automatically compile the project sources before expi, enable the setting: JAR packaging > Build projects if not build automatically option). If you prefer you can also find pre-compiled jars in the MVN repository.
put that jar file in my coldfusion installation's /WEB-INF/lib/
folder.
CF10+ also supports dynamic class loading via a new application level setting THIS.javaSettings.
// Initialize the Java class.
factualClass=CreateObject("java", "src.main.java.com.factual.driver.Factual");
Just as a point of interest, src/main/java/ is not actually part of the libary class name. It is a standard directory structure used in Maven projects. It is probably included when exporting the sources, but not the compiled classes.
You can always verify the correct path and class name either by examining the API ie javadocs or by viewing one the source files. Package declarations are always at the top of the source file, such as on line 1 of src/main/java/com/factual/driver/Factual.java:
package com.factual.driver; // ie "com.factual.driver"
.. and the class declaration on line 39.
public class Factual { // ie "Factual"
Combined that gives you the exact (case-sensitive) path to use with createObject:
factualClass=CreateObject("java", "com.factual.driver.Factual");
I'm in the habit of filling in the META-INF/MANIFEST.MF of every jar file I build with information related to the version of the component, build time, ...
I want my lambda to log that information and/or have it as a part of its output.
In most cases, I can access this with code similar to:
{code}GreatestClassNameEver.class.getPackage().getImplementationVersion(){code}
I tried this with my lambda, but {code}getImplementationVersion(){code} returns null.
After creating an AWS support ticket, it turns out that this isn't possible due to how Lambda extracts the Jar.
When the jar is disassembled it's files are extracted as follows:
class files in /var/task/
libraries in /var/task/lib
properties and other config files in /var/task/resources
but the META-INF directory is not extracted during this process.
The workaround they gave me was to use a plugin to copy the manifest to the Resources directory and read from the /var/task/resources/... to get the information you need.
I am writing a program in java with netbeans IDE which receives a jasper report *.jrxml and then displays the report for the user. I wrote the following line of code for the file path
String reportSource = "src\\jasper-reports\\report.jrxml";
but when I move the dist folder in some other place and try to run the jar file inside it, my program can not find the report.
my problem is that were should I put the *.jrxml file and how to define it's path in my program so that when I want to give my software to someone else it runs without any errors (e.g. the program can find the file)
avoid using absolute paths. try to include the file as a resource in your netbeans project. then in your code you can search for and load the file as
new InputStreamReader((Main.class.getResourceAsStream("/report.jrxml")))
something like that depending on where the file resides in your project
it's more recommended using one of the two approaches:
pass the locations/paths as a -Dproperty=value in the Java application launcher command line http://www.tutorialspoint.com/unix_commands/java.htm
store it the locations/paths in a configurations file with a unique key and edit the file accordingly for different environments,
e.g.this files always stored in ${HOME}/config_files/ directory
absolute paths considered a bad practice
Currently i have placed the Displaytag.properties in 'src' directory, and it is working fine. Is it posssible to have this file on some different location like src/comp/bre/sub/config ?
From the docs for the DisplayTag library:
For the whole web application, create
a custom properties file named
"displaytag.properties" and place it
in the application classpath.
Displaytag will use the locale of the
request object to determine the locale
of the property file to use; if the
key required does not exist in the
specified file, the key will be loaded
from a more general property file.
So in your case make sure your build scripts (or IDE) copy your displaytag.properties file from src/comp/bre/sub/config the onto the classpath.
In an IDE this is normally as simple as specifying that a particular directory contains source code. In ANT just make sure the displaytag.properties file ends up in your /WEB-INF/classes.
Find the code which loads this properties file and add the new path. You can also place it in a folder yourProject/src/resources/ and add it to the classpath. Therefore, your properties file will be placed in the binary folder once the code will be compiled.