This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.



Less than 42 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Creating a File object from a java class, when both are deployed in the same package!  RSS feed

 
Shailesh Deshpande
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a requirement to embed an image in an excel file dynamically from a Java class. The Java class is a part of the web module of an EAR file which is getting deployed in WAS 5.0.

To embed the image in the excel file at the runtime, I need to create a file object for the same. I can do that easily if I save the image somewhere on 'C' drive and provide its exact path to the File class constructor. But I do not want to do that.

Instead I want to bundle the image file in the EAR. I tried this by saving the image file under the same package where the above java class (from where I want to create file object) resides.
But the problem is that, the class is not able to recognize/locate the file and giving 'FileNotFoundException', when I try to embed it in the excel file.

Is there any way we can access the image file from the java class, while bundling it in the EAR file?

Thanks,
Shailesh.
 
Joe Ess
Bartender
Posts: 9406
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does this post give you any ideas?
 
Michael Powe
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Shailesh Deshpande:

Is there any way we can access the image file from the java class, while bundling it in the EAR file?





in some circumstances, this will give you the actual path to the image. i do not know anything about EJBs. however, in JSP, my experience has been that the file has to be somewhere where the "real path" makes sense -- you have to have access to in within the web server context. (e.g., you probably won't be able to access the file if it's on the root directory of the server.) you may be able to determine the real path to the file without actually being able to access it.

thanks.

mp
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!