Search code examples
javaeclipsedependenciessnakeyaml

How to package dependencies into java project with eclipse


I get this error when I try to run my project. java.lang.NoClassDefFoundError: org/yaml/snakeyaml/Yaml

I am trying to include the dependency SnakeYaml.jar in my project so my project is only one jar instead of requiring an external dependency.

in my project SnakeYaml.jar is located at /Libs/SnakeYaml.jar

but it is not being loaded at runtime, what can I do to get it to load the resource at runtime?


Solution

  • The best solution to avoid such problems is creating maven based project by eclipse. when you export your project as jar or war files it puts all dependencies in the jar or war files

    enter image description here