Well, this is a post with a question, and the solution! But, it seems like there is a discrepancy somewhere and not sure if its just my understanding that needs to be corrected, or something code related.
I have an icon in an add on that I’ve made, and I’m referring to it via a ClassResource like this:
ClassResource classResource = new ClassResource(resourcePath, application);
where resource path =
img/icons/add.png
which works fine when I run the application locally. However, it does NOT work when I package as a jar, and I found that I was forced to refer to the icon like this:
/img/icons/add.png
Note the leading slash.
Why is that? I like things to work regardless of the environment (locally running it in or as a jar in another project) so I’m not sure if this means there is something in vaadin that should be changed, or this is just the way things are? Can someone please clarify?