permaculture playing cards
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
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

How to get inside a .ear file

Mahesh Bhatt
Ranch Hand

Joined: Sep 15, 2004
Posts: 88

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


Impossible is I M Possible
Ilja Preuss

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
I agree. Here's the link:
subject: How to get inside a .ear file
It's not a secret anymore!