Unable to import openCV

Hi, Im sorry if this has been asked before, but im new here and want to learn openCV, so when i downloaded version 4.5.1 from sourceforge to use on eclipse with Java, i followed the setup instructions but its still saying that the classes i tried to import dont exist while trying to create the Hello class that they gave to test out if it works.

I basically created a user library, added the jar file, selected the x64 for the native library folder, then added that user library to my class path

one quick question, can you see your opencv-451.jar under your project in the project explorer?
image

I followed Installing OpenCV for Java — OpenCV Java Tutorials 1.0 documentation
Those instructions to set up a user library in Eclipse is pretty good.

I was able to see it, and that was the same tutorial i followed. I figured out what the issue most likely is but not how to resolve it. I use the eclipse ide 2020-12 enterprise edition, so I dont know if it is a new feature but my old laptop didnt have it. Now, a module-info file automatically is created, and when i add the jar and native library to my class path (i tried as a user library and directly and neither worked) and it says i need to add “requires opencv” in the module-info file and switch it to the module path, and once i do this, my “openJDK platform binary” shoots up in cpu usage to fill up whatever is left until i get 100% cpu usage, and freezes and crashes eclipse, so im not sure how to fix that now

Hmmm… I don’t know how much difference between my Eclipse IDE for Enterprise Java Developers Build id: 20200910-1200 and yours. I might have a settings different from yours is that I set all my projects using jdk 1.8.0_251 (you can see my screenshot previous reply). I just checked on Task Manager while running the project MyFxCvApp (a project starting from the openCV tutorial but adding more openCV calls, including checking how many cameras connected to). The CPU only uses 50% in the beginning of App running. My Win10 has 32 GB memory.
I assume you might run in Linux. My Linux PC has only 16 GB memory and I saw the spike when I ran MyFxCvApp in Eclipse (I had the same settings as my Win10). The CPU actually shoot up to 159% in the beginning of Debug mode App running. Later on, it dropped to 65%-90%. So, if your PC doesn’t have lots of memory, you might not be able to run Debug mode.

I figured out what the issue was but I am clueless as to why the issue is occurring. So what it made me do was add “requires opencv” to a file called module-info (never learnt what that is because my old laptop didnt automatically create it when i created a new project, whereas my new laptop does) but the import wouldnt work unless i added that line to module-info and moved my jar file stuff into module path instead of class path. However, adding the line to module-info is what caused my cpu to be fully taken up by openJDK platform binary, and the only solution i found was that if i deleted the module-info file, it worked completely.

Also, it was puzzling because this is a brand new computer I bought less than a month ago thats normally an $1800 gaming laptop, so in terms of strength, it should definitely have been sufficient