Jump to content
We've recently updated our Privacy Statement, available here ×

Reading a Jasper file from JAR


2004 IR Help

Recommended Posts

By: vinay.s - vinay_csp

Reading a Jasper file from JAR

2005-07-22 22:06

Hi,

I am trying to read a jasper file from jar using the following code

jasperPath = "com//Reports/jasper/"+className+".jasper";

jasperURL = ClassLoader.getSystemResource(jasperPath);

 

I am getting a java.io.FileNotFoundException:

Please Help me

Thanks in Advance

 

vinay

 

 

 

 

 

 

By: Bob Withers - bwit

RE: Reading a Jasper file from JAR

2005-07-23 08:04

Is the jar you are trying to load the file from in the system classpath? If not try:

 

getClass().getClassLoader().getResource(jasperPath);

 

You can also use getClass().getResource() but you will need to add a '/' to the start of the path.

 

Bob

 

 

 

 

 

By: Code_Slave - code_slave

RE: Reading a Jasper file from JAR

2005-07-25 06:38

or make the report part of your class

I.E "MyProvidesReports"

, in a folder called "ReportsSource"

 

public InputStream getSourceFile() {

//java.net.URL imgURL;

InputStream Source;

Source = MyProvidesReports.class.getResourceAsStream(

"/ReportsSource/PDAN.xml"); // this is a fixed format for all java platforms do not use "file.separator

 

return Source;

}

 

that's what i used to do

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...