访问.jar文件中的报告 [英] Accessing report inside a .jar file

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

问题描述

伙计们,正如标题所暗示的那样.当我清理程序并将其构建为要部署的jar文件时,无法访问我的报告.我尝试在互联网上浏览以寻求可能的解决方案,但没有一个能解决问题.因此,下面是我尝试访问jar文件中的报告的操作:

So guys, as what the title implies. I cant access my report when i clean and build my program to a jar file to be deployed. I tried surfing the internet for possible solutions but none of them has gone right. So below is what i did to try to access the report inside the jar file:

URL reportURL = getClass().getClassLoader().getResource("assessmentrecordsystem\\reports\\report1.jrxml");//returns nothing

reportInputStream = this.getClass().getClassLoader().getResourceAsStream("\\reports\\report1.jrxml");//all so returns nothing

我想念什么?

这是我的jar文件包含的内容:

This is what my jar file contains:

推荐答案

考虑这样的结构:

myjar.jar
  |__ assessmentrecordsystem
        |__ MyClass.class
        |__ reports
              |__ report1.jrxml

您可以使用

否则,您需要将以下条目添加到jar内的/META-INF/MANIFEST.MF文件中:

Otherwise, you need to add the following entry to the /META-INF/MANIFEST.MF file inside your jar:

Class-Path: .

然后,您可以使用

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

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