# add\_jar and resources - relative path question

**URL:** https://discourse.cmake.org/t/add-jar-and-resources-relative-path-question/3187
**Category:** Code
**Created:** [April 21, 2021, 5:48pm UTC](https://discourse.cmake.org/t/add-jar-and-resources-relative-path-question/3187 "2021-04-21T17:48:58Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Jack\_Smith](https://discourse.cmake.org/user_avatar/discourse.cmake.org/jack_smith/32/4425_2.png) [@Jack\_Smith](https://discourse.cmake.org/u/Jack_Smith)
#### Post date: [April 21, 2021, 5:48pm UTC](https://discourse.cmake.org/t/add-jar-and-resources-relative-path-question/3187/1 "2021-04-21T17:48:58Z")

</div>

I am using add\_jar with reasonable success, except . . .

I want to add graphic resources, which I am able to do ONLY by specifying relative paths (which itself is a little strange); but, that isn’t exactly the problem.

The issue is that the relative path becomes the resource path within the jar file.

I need to be able to specify the resource path as it will appear in the jar.  
I am collecting resource files from various paths, but want them all within a single namespace.

So, let’s say, I have :

SRC / path / to / resource1  
SRC / path / to / another / resource2

in the jar file I want them appear like this:

[jar] . my.name.space.resources.resource1  
[jar] . my.name.space.resources.another.resource2

Currently, I don’t see a way to make that happen.

I can get the resources to appear within the jar, but they appear in their own relative paths. ex:

path.to.resource1  
path.to.another.resource2

What’s the best way to accomplish this ?

Thanks for the help

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [April 21, 2021, 6:08pm UTC](https://discourse.cmake.org/t/add-jar-and-resources-relative-path-question/3187/2 "2021-04-21T18:08:31Z")

</div>

I think Java cares a lot about the on-disk structure, so you might need to have `my/name/space` in your source tree. But that’s just my observation; there may be ways of injecting a prefix to a tree.

---

<div class="post-metadata">

### Author: ![marc.chevrier](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/m/ecb155/32.png) [@marc.chevrier](https://discourse.cmake.org/u/marc.chevrier)
#### Post date: [April 22, 2021, 1:52pm UTC](https://discourse.cmake.org/t/add-jar-and-resources-relative-path-question/3187/3 "2021-04-22T13:52:24Z")

</div>

Currently, the only possibility, as explained by @ben.boeckel is to organize your sources in the expected file tree.

---

<div class="post-metadata">

### Author: ![Jack\_Smith](https://discourse.cmake.org/user_avatar/discourse.cmake.org/jack_smith/32/4425_2.png) [@Jack\_Smith](https://discourse.cmake.org/u/Jack_Smith)
#### Post date: [April 22, 2021, 3:26pm UTC](https://discourse.cmake.org/t/add-jar-and-resources-relative-path-question/3187/4 "2021-04-22T15:26:42Z")

</div>

Actually, I found it easier to add a parameter to add\_jar.

I’ll submit a patch
