This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes How to get inside a .ear file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "How to get inside a .ear file" Watch "How to get inside a .ear file" New topic
Author

How to get inside a .ear file

Mahesh Bhatt
Ranch Hand

Joined: Sep 15, 2004
Posts: 88
Hi,

I have a java code, at a particular point in this class, I was reading a file. I used to give the path as C:\temp\subTemp\myfile.xml.

Now i have to access a file from inside an .ear file, how do I go about giving the path?
How to get inside the .ear file. What path do I use.
NOTE: I have to place the class file outside the .ear file

Regards,
Prashant


Impossible is I M Possible
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Remember that an ear file basically is a jar file with some special content. So you can use a jar-URL to reference files inside it:

jar:file athToEar/myEar.ear!/pathInsideEar/myfile.xml


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to get inside a .ear file
 
Similar Threads
looking for java free diameter
how to update a class file
Ejb ClassLoader
how to specify the path for DocumentBuilder.parse
how to view .jws from .ear file