java io FileNotFoundException Template ftl not found

java io FileNotFoundException Template ftl not found

It is very common issue while working with FreeMarker template created *.ftl not found. First thing we should do is to set classpath wherever we kept template file.

java.io.FileNotFoundException: Template “JavaHonkFreeMarkerTemplate.ftl” not found

  • Solution: Before using FreeMarker template you will have to set template loader and give path from where FreeMarker will load the template. In below example I have include how to set template loader and in case one path fail you could use another and example I am catching exception and loading another in catch block (It’s not preferable). In real time you definitely should know the actual path where file is available.

FreeMarketTemplateLoad.java:

  • Output:

java io FileNotFoundException Template ftl not found

  • For more information please visit FreeMarker site here

Leave a Reply

Your email address will not be published. Required fields are marked *