My directory structure inside the compiled jar looks like this (Spring Boot Structure):
- BOOT-INF
- classes
- ...
- templates
- Java_Template.ftl
- lib
- ...
- org
- ...
- META-INF
- ...
and I need to get the path of Java_Template.ftl relative to the .jar root (BOOT-INF\classes\templates\Java_template.ftl
) as a String, but I don't want to hardcode the BOOT-INF\classes\
part, so how do I get it?
I've tried this.getClass().getClassLoader().getResource("templates/Java_template.ftl").toString()
but it returns the path relative to C: (or some other drive), which is not what I need.
My required result: BOOT-INF\classes\
Or: BOOT-INF\classes\templates\Java_template.ftl