访问jar文件中的报告的问题 [英] Problems to access a report in a jar file

查看:162
本文介绍了访问jar文件中的报告的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含多个报告的jar应用程序(文件 .jasper )以及我获取报告路径的方式是:

I have a jar application that contains several reports (files .jasper) and the way that I get the path of the report is:

getClass().getResource("/reportes/mireporte.jasper").toString();

但是当我执行时我得到下一个错误: FileNotFoundException
虽然当我用winrar打开它时报告在jar文件中。

but when I execute I get the next error: FileNotFoundException although the report is within the jar file when I open it with the winrar.

我的问题是:


  1. 这是获取jar文件中报告路径的方法吗?

  2. 是否可以打开内部报告一个jar文件?


推荐答案

为什么要将资源转换为String?

Why are you converting the resource to String ??

尝试使用(取决于你想如何使用资源):

Try to use (depending on how you want to use the resource):


  • getResource(/ report / mireporte.jasper)。getFile()

getResource(/ report / mireporte.jasper)。getInputStream()

来自'getResource'的返回对象是URL:

Returned object from 'getResource' is URL:

  • http://download.oracle.com/javase/1.4.2/docs/api/java/net/URL.html

这篇关于访问jar文件中的报告的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆