Re: [OpenMap Users] Issues with OpenMap in a jar file

From: Don Dietrick <dietrick_at_bbn.com>
Date: Fri, 12 Jun 2009 08:57:08 -0400

The "/" at the front of the path seems odd for a resource in a jar file,
usually it's a relative path that just happens to be from the root of
the jar file.

If the PropUtils can't find it, then it's likely there's something wrong
with the path. That's the method I use in OpenMap to load icons into
buttons.

- Don

Mulone wrote:
> Thanks Don!
>
> I'm reading the png file in byte arrays with
> http://www.copypastecode.com/6124 and then I load them into a
> ByteRasterLocation ( http://www.copypastecode.com/6128 ).
>
> The png files are definitely in the jar file but the
> PropUtils.getResourceOrFileOrURL can't find them.
> This code:
>
> String path = fileRelativePath.replace("\\", "/");
> InputStream in = OSMSettings.class.getClassLoader().getResourceAsStream(
> "/"+path );
> if (in==null)
> in = OSMSettings.class.getClassLoader().getResourceAsStream( path );
>
> finds the file, but then when I try to render the ByteRasterLocation I get
> that weird error message.
>
> Any ideas?
>
> Mulone
>
>
>
> Don Dietrick wrote:
>
>> Hi Mulone,
>>
>> You should be able to load a png using an ImageIcon, created using a
>> URL. Create the URL using PropUtils.getResourceOrFileOrURL(String
>> path), where the path is a relative path to the png from the root of the
>> jar file.
>>
>> - Don
>>
>> Mulone wrote:
>>
>>> PS: when I run the exact same code on Eclipse it works fine... I get the
>>> error just when I run it from the executable jar with java -jar
>>> myapplication.jar
>>>
>>>
>>> Hi everybody,
>>> I've been messing with my openmap-based application to make it work in a
>>> executable jar file... It's not as easy as it might look.
>>>
>>> The most annoying issue I've come across is related to the png files I
>>> use
>>> to display icons: given that I can't use a simple FileInputStream in a
>>> jar
>>> file I wrote this function: http://www.copypastecode.com/6107/
>>> [...]
>>>
>>>
>> --
>> [To unsubscribe to this list send an email to "majdart_at_bbn.com"
>> with the following text in the BODY of the message "unsubscribe
>> openmap-users"]
>>
>>
>>
>
>

--
[To unsubscribe to this list send an email to "majdart_at_bbn.com"
with the following text in the BODY of the message "unsubscribe openmap-users"]
Received on Fri Jun 12 2009 - 08:57:56 EDT

This archive was generated by hypermail 2.3.0 : Tue Mar 28 2017 - 23:25:09 EDT