Reputation: 345
I am trying to use opencv 2.4.9. in a Java Servlet with NetBeans, i have two files - the first one is a Servlet java file Login.java which is called by index.html , and the second one is CamCap.java a java file with all the opencv imports but this file is in the same package, am calling a function of second java file from the first one. The two files run fine separately as java project but when I try to run the complete servlet project it throws this
Error - (java.lang.NoClassDefFoundError: org/opencv/core/Core)
How to resolve this!!?
Upvotes: 2
Views: 7500
Reputation: 51721
You need to make your OpenCV jar available to both the IDE as well as the application server. I believe you've already made it available to your IDE by adding it to your web project's classpath.
Now to satisfy the dependency when running on the application server too, just copy the jar to your web project's /WEB-INF/lib
directory, build your war
and deploy it again.
I suggest you to always copy your dependency to /WEB-INF/lib
first, and then adding it to your project's classpath. This takes care of such errors and also makes sure that both the IDE and the application server are using the same version of the jar.
Upvotes: 5