You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@uima.apache.org by Ahmed Abdeen Hamed <ah...@gmail.com> on 2008/08/08 20:19:14 UTC

Making JAR files reading from within

Hello,Is there a way to tell a jar file to access its contents (txt and
config) files instead of looking for such files on the filesystem? I created
a UIMA-based application and it is successfully working from my machine
using the command-line. However, if I put the jar on another machine it
doesn't look inside itself to access model files for examples. I have been
looking into options and I found out that there is a way to access the
jars's internals one file at a time, and read it contents online at at time.
However, that makes me reinvent my application again to get it to manipulate
the files from the jars even though my program has already done that. Is
there a flag that you can turn on to tell the the jar to access its contents
vs redoing this again programatically?
Thank you for you help!
-Ahmed

Re: Making JAR files reading from within

Posted by Ahmed Abdeen Hamed <ah...@gmail.com>.
Sorry, the email was prematurely sent while I was still typing.
I was saying I am sure I will have further questions :)
Thanks Marshall!
Ahmed

On Thu, Aug 14, 2008 at 4:54 PM, Ahmed Abdeen Hamed <ahmed.elmasri@gmail.com
> wrote:

> Dear Marshall: Timing is amazing! I was just looking into other options to
> deploy. I played with PEAR packaging briefly and I didn't know ho to use it
> to run command line applications not just AE. However, I will look into it
> again since I am struggling with another application that it still can't see
> the uima-core.jar. It has been two days already fiddling with it and I just
> can't get it to see that jar.
>
> Thank you and I will share my experience as I am sure
>
>
> On Thu, Aug 14, 2008 at 4:46 PM, Marshall Schor <ms...@schor.com> wrote:
>
>> Hi Ahmed -
>>
>> Did you consider UIMA's "PEAR" packaging and the pear installer utilities
>> that are part of UIMA?
>>
>> That's how many people make annotator components available to others.
>>
>> -Marshall
>>
>>
>> Ahmed Abdeen Hamed wrote:
>>
>>> Dear Marshall: Thank you for taking the time to response to this. You
>>> have
>>> inspired a couple of suggestions that we ended up using here to deploy
>>> our
>>> application. So, it's finally usable by someone else except myself, yay
>>> :)Best
>>> wishes,
>>> -Ahmed
>>>
>>>
>>>
>>
>

Re: Making JAR files reading from within

Posted by Ahmed Abdeen Hamed <ah...@gmail.com>.
Dear Marshall: Timing is amazing! I was just looking into other options to
deploy. I played with PEAR packaging briefly and I didn't know ho to use it
to run command line applications not just AE. However, I will look into it
again since I am struggling with another application that it still can't see
the uima-core.jar. It has been two days already fiddling with it and I just
can't get it to see that jar.

Thank you and I will share my experience as I am sure


On Thu, Aug 14, 2008 at 4:46 PM, Marshall Schor <ms...@schor.com> wrote:

> Hi Ahmed -
>
> Did you consider UIMA's "PEAR" packaging and the pear installer utilities
> that are part of UIMA?
>
> That's how many people make annotator components available to others.
>
> -Marshall
>
>
> Ahmed Abdeen Hamed wrote:
>
>> Dear Marshall: Thank you for taking the time to response to this. You have
>> inspired a couple of suggestions that we ended up using here to deploy our
>> application. So, it's finally usable by someone else except myself, yay
>> :)Best
>> wishes,
>> -Ahmed
>>
>>
>>
>

Re: Making JAR files reading from within

Posted by Marshall Schor <ms...@schor.com>.
Hi Ahmed -

Did you consider UIMA's "PEAR" packaging and the pear installer 
utilities that are part of UIMA?

That's how many people make annotator components available to others.

-Marshall

Ahmed Abdeen Hamed wrote:
> Dear Marshall: Thank you for taking the time to response to this. You have
> inspired a couple of suggestions that we ended up using here to deploy our
> application. So, it's finally usable by someone else except myself, yay :)Best
> wishes,
> -Ahmed
>
>   

Re: Making JAR files reading from within

Posted by Ahmed Abdeen Hamed <ah...@gmail.com>.
Dear Marshall: Thank you for taking the time to response to this. You have
inspired a couple of suggestions that we ended up using here to deploy our
application. So, it's finally usable by someone else except myself, yay :)Best
wishes,
-Ahmed

Re: Making JAR files reading from within

Posted by Marshall Schor <ms...@schor.com>.

Ahmed Abdeen Hamed wrote:
> Hi Hannes,Thank you for your response.
> I have configuration files, UIMA descriptors, models and dictionaries in my
> JAR. After I deployed, the JAR is not able to see those files inside itself
> and I get FIleNotFoundException when I run the JAR file the command line.
> This problem disappears entirely if I extract the JAR and the files are
> copied into the file system. My question is, how do I tell the JAR that
> those files are already inside it instead of extracting it? The suggestion
> you have given me is very handy in the case of reading a simple file
> contents. But if the JAR can't see the applications' descriptors then
> getting the contents as streams becomes very messy because those descriptors
> have references to other descriptors. So, I am not still sure how to tell
> the JAR to access all the descriptors as one problem I have with the JAR.
> Any other suggestions?
> Thanks again!
> Ahmed
>   
Here are perhaps 2 solutions:

1) run a process that extracts the Jar contents into the file system, at 
a "well known" location (maybe a temp directory), before running the 
application :-)

2) I don't think there is a general solution for this.  For the 
particular case of reading the XML descriptors, where the descriptors 
might "import" other descriptors, this can be supported in Jar files by 
writing the Apache UIMA "import" elements using the "name=" attribute 
rather than the "location=" attribute.  When you use the name= 
attribute, the name is looked up in the current Java class path to 
locate the resource.  The name must not include the final ".xml" - that 
is appended automatically.  And you can specify which subdirectory in 
the JAR archive the file is located in, by prefixing name with the 
containing directories (if any) separated by the "period" character "." 
-- this is the same convention used by Java itself when locating classes 
within packages.

-Marshall
> On Mon, Aug 11, 2008 at 5:37 AM, Hannes Carl Meyer <
> hannescarl@googlemail.com> wrote:
>
>   
>> Hi Ahmed,
>> yes it is possible to access files from inside the jar, but in which
>> context? In plain Java you can do something like this:
>>
>> YourClass.class.getClassLoader().getResourceAsStream("yourpackage/resource");
>> Regards
>> Hannes
>>
>> 2008/8/8 Ahmed Abdeen Hamed <ah...@gmail.com>
>>
>>     
>>> Hello,Is there a way to tell a jar file to access its contents (txt and
>>> config) files instead of looking for such files on the filesystem? I
>>> created
>>> a UIMA-based application and it is successfully working from my machine
>>> using the command-line. However, if I put the jar on another machine it
>>> doesn't look inside itself to access model files for examples. I have
>>>       
>> been
>>     
>>> looking into options and I found out that there is a way to access the
>>> jars's internals one file at a time, and read it contents online at at
>>> time.
>>> However, that makes me reinvent my application again to get it to
>>> manipulate
>>> the files from the jars even though my program has already done that. Is
>>> there a flag that you can turn on to tell the the jar to access its
>>> contents
>>> vs redoing this again programatically?
>>> Thank you for you help!
>>> -Ahmed
>>>
>>>       
>
>   

Re: Making JAR files reading from within

Posted by Ahmed Abdeen Hamed <ah...@gmail.com>.
Hi Hannes,Thank you for your response.
I have configuration files, UIMA descriptors, models and dictionaries in my
JAR. After I deployed, the JAR is not able to see those files inside itself
and I get FIleNotFoundException when I run the JAR file the command line.
This problem disappears entirely if I extract the JAR and the files are
copied into the file system. My question is, how do I tell the JAR that
those files are already inside it instead of extracting it? The suggestion
you have given me is very handy in the case of reading a simple file
contents. But if the JAR can't see the applications' descriptors then
getting the contents as streams becomes very messy because those descriptors
have references to other descriptors. So, I am not still sure how to tell
the JAR to access all the descriptors as one problem I have with the JAR.
Any other suggestions?
Thanks again!
Ahmed

On Mon, Aug 11, 2008 at 5:37 AM, Hannes Carl Meyer <
hannescarl@googlemail.com> wrote:

> Hi Ahmed,
> yes it is possible to access files from inside the jar, but in which
> context? In plain Java you can do something like this:
>
> YourClass.class.getClassLoader().getResourceAsStream("yourpackage/resource");
> Regards
> Hannes
>
> 2008/8/8 Ahmed Abdeen Hamed <ah...@gmail.com>
>
> > Hello,Is there a way to tell a jar file to access its contents (txt and
> > config) files instead of looking for such files on the filesystem? I
> > created
> > a UIMA-based application and it is successfully working from my machine
> > using the command-line. However, if I put the jar on another machine it
> > doesn't look inside itself to access model files for examples. I have
> been
> > looking into options and I found out that there is a way to access the
> > jars's internals one file at a time, and read it contents online at at
> > time.
> > However, that makes me reinvent my application again to get it to
> > manipulate
> > the files from the jars even though my program has already done that. Is
> > there a flag that you can turn on to tell the the jar to access its
> > contents
> > vs redoing this again programatically?
> > Thank you for you help!
> > -Ahmed
> >
>

Re: Making JAR files reading from within

Posted by Hannes Carl Meyer <ha...@googlemail.com>.
Hi Ahmed,
yes it is possible to access files from inside the jar, but in which
context? In plain Java you can do something like this:
YourClass.class.getClassLoader().getResourceAsStream("yourpackage/resource");
Regards
Hannes

2008/8/8 Ahmed Abdeen Hamed <ah...@gmail.com>

> Hello,Is there a way to tell a jar file to access its contents (txt and
> config) files instead of looking for such files on the filesystem? I
> created
> a UIMA-based application and it is successfully working from my machine
> using the command-line. However, if I put the jar on another machine it
> doesn't look inside itself to access model files for examples. I have been
> looking into options and I found out that there is a way to access the
> jars's internals one file at a time, and read it contents online at at
> time.
> However, that makes me reinvent my application again to get it to
> manipulate
> the files from the jars even though my program has already done that. Is
> there a flag that you can turn on to tell the the jar to access its
> contents
> vs redoing this again programatically?
> Thank you for you help!
> -Ahmed
>