Also tried `this.javaClass.classLoader.getResource...
# announcements
u
Also tried
this.javaClass.classLoader.getResourceAsStream("patterns.ini")
and put
patterns.ini
in the package of class in
resources
- nothing helps
d
You put it in the package of the class? Then call
getResourceAsStream
on the class, not the loader.
Also, if the path should be relative to the root package, do the same and prepend it with a '/' instead.
u
i've tried using both
javaClass.getRes..
and `javaClass.classLoader.getRes..`:
Снимок экрана 2019-01-31 в 11.16.13.png
Снимок экрана 2019-01-31 в 11.18.28.png
really strange, i can see res file in
build
directory:
Снимок экрана 2019-01-31 в 11.19.38.png
oh, it's IDE (IntelliJ IDEA 2018.3.4 CE) bug - if running from IDE it fails:
Снимок экрана 2019-01-31 в 11.26.59.png
but if running from cmd with
./gradle clean :lib:jvmTest
it succeeds:
Снимок экрана 2019-01-31 в 11.28.12.png
Any workaround? eg. build with gradle (not with IDE) and reuse compiled artifacts (classes, resources). I've tried to use Gradle-aware build but failed to find the right target:
Снимок экрана 2019-01-31 в 11.49.22.png
s
when I had this issue I had to put a
/
in front of the path
so instead of
javaClass.getResourceAsStream("patterns.ini")
instead do
javaClass.getResourceAsStream("/patterns.ini")