2

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!!? enter image description here

2
  • NoClassDefFoundError happens when a class is missing at runtime. Could you check if the OpenCV jar is there on runtime classpath? Commented Jun 20, 2015 at 17:06
  • yup its there on runtime classpath :\ Commented Jun 20, 2015 at 17:28

1 Answer 1

5

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.

Sign up to request clarification or add additional context in comments.

3 Comments

@KaranJeet Glad to know this helped.
@KaranJeet i am facing same issue, would u please show me how to make the opencv jar available to the application server, actually i am new in j2ee technology. -Thanks
@Al Noman First add opencv._.jar to your project Right click 'libraries' in the project list, then click add. Then load dll in your java class(there are other ways to load but this eliminated my error) static{ System.load(new File("C:\\Users\\Paradox\\Documents\\NetBeansProjects\\Servlet3\\lib\\opencv_java249.dll").getAbsolutePath());} (replace it with your path to opencv_java_.dll )

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.