logo       

Re: Use of Jasperreprt file from .jar file: msg#00000

java.jasperreports.general

Subject: Re: Use of Jasperreprt file from .jar file


Md. Mortoza Ali Khan <mortoza_khan@...> writes:

>
> Hi
> I want to put all my jasperreport files into a jar
> file (reports.jar) and want to call/use from java
> program. Can you help me how do I get the file and
> use?
> Rgds,
> MAK
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
>


Hi Mortoza,

You just need create a class to Load any files that stay in your jar file.

That's the one way you can use:

- class name: LoadReport.java

// this is a subreport by name repassePeriodoResumido.jasper
public static final String REL_REPASSE_RESUMIDO =
"/com/reports/repassePeriodoResumido.jasper";
public static final String REL_REPASSE_ORGAO_AUTUADOR_RESUMIDO =
"repasseOrgaoAutuadorResumido.jasper";

public String getURLFile(String arquivo) {
Object obj = this.getClass().getResource(arquivo);
if (obj != null)
return ((URL) obj).toString();
return "";
}

in your main report create a parameter will receive the path of the sub-report.
For example: $P{SUB_REPORT}. In your class create a HashMap and insert the key
"SUB_REPORT" and, your value will be
loadReport.getURLFile(LoadReport.REL_REPASSE_RESUMIDO);

With this way you can load the sub-report.

Regards

David Farias - Brazil - PA
davidnfarias-Re5JQEeQqe8AvxtiuMwx3w@xxxxxxxxxxxxxxxx



Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise