cannot run javacv example, ClassNotFoundException (Mac OS X)
Closed this issue · 9 comments
GoogleCodeExporter commented
What steps will reproduce the problem?
1. Install opencv from Mac Ports (
http://opencv.willowgarage.com/wiki/Mac_OS_X_OpenCV_Port )
2. Downloaded javacv
3. Created example Smoother.java:
import static com.googlecode.javacv.cpp.opencv_core.*;
import static com.googlecode.javacv.cpp.opencv_imgproc.*;
import static com.googlecode.javacv.cpp.opencv_highgui.*;
public class Smoother {
public static void main(String filename) {
IplImage image = cvLoadImage(filename);
if (image != null) {
cvSmooth(image, image, CV_GAUSSIAN, 3);
cvSaveImage(filename, image);
cvReleaseImage(image);
}
}
}
4. compiled
$ javac -cp ./javacv.jar Smoother.java
5. ran
$ java -cp ./javacv.jar Smoother
What is the expected output? What do you see instead?
$ java Smoother
Exception in thread "main" java.lang.NoClassDefFoundError:
com/googlecode/javacv/cpp/opencv_core$CvArr
Caused by: java.lang.ClassNotFoundException:
com.googlecode.javacv.cpp.opencv_core$CvArr
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
$ java -cp ./javacv.jar Smoother
Exception in thread "main" java.lang.NoClassDefFoundError: Smoother
Caused by: java.lang.ClassNotFoundException: Smoother
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
$ java -cp ./javacv.jar:./ Smoother
Exception in thread "main" java.lang.NoSuchMethodError: main
What version of the product are you using? On what operating system?
* Mac OS X 10.7.2
* OpenCV 2.3.1a (from MacPorts)
* JavaCV (bin 2011-10-01)
Please provide any additional information below.
Not a dup of
http://code.google.com/p/javacv/issues/detail?id=125&can=1&sort=-id, this is a
test from compiling at the command line (removing any potential Eclipse
complications)
Original issue reported on code.google.com by andrew.c...@gmail.com
on 3 Nov 2011 at 5:21
GoogleCodeExporter commented
Hum, looks like MacPorts does not add its libraries in the path by default. We
can work around this by setting the DYLD_FALLBACK_LIBRARY_PATH environment
variable, e.g.:
export DYLD_FALLBACK_LIBRARY_PATH=/opt/local/lib/
This directory will be hardcoded next time I recompile JavaCV with MacPorts,
well unless OpenCV 2.3.2 or something comes out and MacPorts takes another few
months to follow...
Original comment by samuel.a...@gmail.com
on 4 Nov 2011 at 4:12
- Changed title: cannot run javacv example, ClassNotFoundException (Mac OS X)
- Changed state: Started
GoogleCodeExporter commented
Well, oddly enough now I can run the javacv example just fine in Eclipse,
though still having some issue with the classpath on the command line.
What changed is I rebuilt libpng in Mac Ports. I can link to the thread
discussing it there if you wish.
Original comment by andrew.c...@gmail.com
on 4 Nov 2011 at 8:49
GoogleCodeExporter commented
[deleted comment]
GoogleCodeExporter commented
I got it. Thanks anyway.
Original comment by bphan...@gmail.com
on 22 Nov 2011 at 3:31
GoogleCodeExporter commented
Mind sharing your solution?
Original comment by andrew.c...@gmail.com
on 22 Nov 2011 at 2:09
GoogleCodeExporter commented
Typing the export command above in a Terminal window does not work?
Original comment by samuel.a...@gmail.com
on 26 Nov 2011 at 6:04
GoogleCodeExporter commented
If you are running it in Eclipse simply add the environment variable
DYLD_FALLBACK_LIBRARY_PATH=/opt/local/lib in the debug/run configuration and
that should work. Otherwise if you run from the command line having it set in
your env should also work.
Original comment by triggull...@gmail.com
on 29 Nov 2011 at 5:37
GoogleCodeExporter commented
export DYLD_FALLBACK_LIBRARY_PATH=/opt/local/lib/
also worked for me.
(OSX)
Original comment by jerda...@speakeasy.net
on 2 Dec 2011 at 6:35
GoogleCodeExporter commented
Fixed in latest release!
Original comment by samuel.a...@gmail.com
on 8 Jan 2012 at 3:46
- Changed state: Fixed