String Template Group File can use resource?

1.8k Views Asked by At

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?

1

There are 1 best solutions below

1
On BEST ANSWER

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");