Search code examples
javaantlr4stringtemplate-4

String Template Group File can use resource?


On a java project using Antlr4 and String Template 4 can I get a STGroupFile from a resource contained in project's jar?

I made it works using the absolute path, like

STGroup gd = new STGroupFile("D:\\templates\\bbx.stg");

But I would like to have the .stg file inside the jar.

What am I missing?


Solution

  • You should be able to access a file within any jar file in the class path by using a relative path syntax:

    STGroup group = new STGroupFile("templates/bbx.stg");