Jar with images
Is it possible to create pure resource jar? I'm working on swing application, just added one module, the layout looks like this:
resources -> icons -> abcd.png
Then in project structure I marked resources and icons as source folders, then in Build - Build Jars.. I checked module to Jar. When I'm choosing packaging method "Copy module output to..." IDEA produces resources.jar with 'META-INF' and 'abcd.png', there is no 'icons/abcd.png'. If I choose "Jar module output and copy file to..." it produces resources.jar which contains resources.jar again which contains 'META-INF' and 'abcd.png', but still no 'icons/abcd.png'.
Is it possible to force it to produce original package layout, like 'icons/...'?
Thank you in advance.
Please sign in to leave a comment.
Hello LightDruid,
You need to set off "source folder" mark from icons folder and use "Copy
module output" option.
Also you need to have *.png files in the list of Settings / Compiler / Resource
patterns, but this is already done.
Alexander.
Hello Alexander,
Thank you for response, but it looks like it does not work. This is original layout and contents of the jar file:
$ ls -lR resources
resources:
total 2
drwxr-xr-x 2 as mkpasswd 0 Feb 28 17:26 icons
-rw-r
r1 as mkpasswd 961 Feb 28 17:28 resources.iml-rw-r
r1 as mkpasswd 216 Feb 28 17:30 resources.jarresources/icons:
total 11
-rw-r
r1 as mkpasswd 11042 Sep 3 22:07 tix.png$ jar tf resources/resources.jar
META-INF/MANIFEST.MF
>
Hello LightDruid,
Have you compiled your module before making jar? Jar builder takes compiler's
output, so, this output should exist before jarring.
If the module contains no java files, compiler just copies resources to the
output folder.
>> Hello LightDruid,
>>
>> You need to set off "source folder" mark from icons
>> folder and use "Copy
>> module output" option.
>> Also you need to have *.png files in the list of
>> Settings / Compiler / Resource
>> patterns, but this is already done.
>>> Is it possible to create pure resource jar? I'm
>>>
>> working on swing
>>
>>> application, just added one module, the layout
>>>
>> looks like this:
>>
>>> resources -> icons -> abcd.png
>>>
>>> Then in project structure I marked resources and
>>>
>> icons as source
>>
>>> folders, then in Build - Build Jars.. I checked
>>>
>> module to Jar. When
>>
>>> I'm choosing packaging method "Copy module output
>>>
>> to..." IDEA produces
>>
>>> resources.jar with 'META-INF' and 'abcd.png', there
>>>
>> is no
>>
>>> 'icons/abcd.png'. If I choose "Jar module output
>>>
>> and copy file to..."
>>
>>> it produces resources.jar which contains
>>>
>> resources.jar again which
>>
>>> contains 'META-INF' and 'abcd.png', but still no
>>>
>> 'icons/abcd.png'.
>>
>>> Is it possible to force it to produce original
>>>
>> package layout, like
>>
>>> 'icons/...'?
>>>
>>> Thank you in advance.
>>>
>> Alexander.
>>
Alexander.
Hello, Alexander,
Thank you very much! I didn't compile it, that's the problem. Now it's ok!