0

First of all, this question has been asked before here,here and here but none of the answers could help me. I just created an example project to test velocity:

public static void main(String[] args) throws IOException {

VelocityEngine velocityEngine = new VelocityEngine();
velocityEngine.setProperty("resource.loader", "class");
velocityEngine.setProperty("class.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
velocityEngine.init();

VelocityContext context = new VelocityContext();
context.put("name", "World");

Template template = Velocity.getTemplate("test.vm");

Writer writer = new OutputStreamWriter(System.out);

template.merge(context, writer);

writer.close();     

}

The template test.vm is in the same folder as the mainclass. I get always ResourceNotFoundException when trying to run this program. According to the docs and answers in the previous questions this should work. Any Ideas why it does not?

p.s. I also tried the other properties suggested in the answers.

Community
  • 1
  • 1
Metalzwerg
  • 23
  • 1
  • 7
  • How is your project setup? Do you use a build tool such as maven? And how do you run your code (command line java, from ide etc.)? – Mustafa Aug 14 '15 at 17:46
  • @Mustafa - No, i don't use Maven, I just added `velocity-1.7-dep.jar` to the build path using Eclipse. I also try to run it in Eclipse. – Metalzwerg Aug 14 '15 at 17:57
  • can you include a screenshot of your eclipse project hiearchy? – Mustafa Aug 14 '15 at 18:48
  • @Mustafa - I don't have enough reputation to add images directly [here is a link](http://i.stack.imgur.com/C7rsK.png) – Metalzwerg Aug 14 '15 at 19:21

0 Answers0