Closed LoveraSantiago closed 5 years ago
I don't use sshexec, so I don't know if that's a factor or not.
The NoClassDefFoundError exception is a confusing and misleading exception that has caused countless hours of wasted time over the entire history of Java - it would have been so much better if the root cause exception was available, like in most other Java exception classes. What it most likely means in cases like this is that the class was found on the classpath but some static initialisation failed in the class it is trying to load.
The only "strange" thing about PictureCaptureHandler is that it is a generic class, i.e. it has a type parameter.
If you try and load that class on a JDK that does not know about generic types, maybe this is your problem.
So, make sure you are using a Java 7 or later JDK to run your project.
Hi Caprica... Thank you for the previous response. I spended some time trying to solve this problem. I figured out that on my jar, after make a unzip, I cant find any library dependencie inside him.
I'm using maven and making my builds with mvn -clean install That's my problem right? it's havent any dependencie inside my jar.
In that case you need to read up a bit more on using jar files and setting classpaths. You don't need to unzip anything.
I can try and summarise, but for the fine detail you'll need to find a tutorial.
One way to do it is this (assuming you copied all the jars to your Pi), create a shell script similar to this:
java -cp your-project.jar:picam-1.1.0.jar:jna-5.2.0.jar:slf4j-api-1.7.26.jar your.main.class
You can omit "your.main.class" if your-project.jar contains a MANIFEST.MF file with a Main-Class attribute.
You could also use the Maven Shade or Onejar plugin. If you look at the pom.xml in the picam project you will see this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<finalName>${project.artifactId}-${project.version}-all</finalName>
</configuration>
</execution>
</executions>
</plugin>
You could do something similar in your own project, and you would end up with a single jar file for your project that contained all of the dependencies within it. You can also add a main-class in the configuration, so on your Pi you would just do this:
java -cp my-big-jar-with-dependencies.jar
But really if this is your issue it's nothing specifically to do with picam at all.
Hi Caprica. I completally agree. This issue doesnt have any relation with picam. Thank you for your atention.
Cheers!
Hi. First of all, thank you for this Camera Pi Project!
I'am not sure if this is the right place to make questions. If not sorry.
Second. I'm getting java.lang.NoClassDefFoundError: uk/co/caprica/picam/PictureCaptureHandler when run my jar. Any sugestion please?
Error: A JNI error has occurred, please check your installation and try again [sshexec] Exception in thread "main" [sshexec] java.lang.NoClassDefFoundError: uk/co/caprica/picam/PictureCaptureHandler [sshexec] at java.lang.Class.getDeclaredMethods0(Native Method) [sshexec] at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) [sshexec] at java.lang.Class.privateGetMethodRecursive(Class.java:3048) [sshexec] at java.lang.Class.getMethod0(Class.java:3018) [sshexec] at java.lang.Class.getMethod(Class.java:1784) [sshexec] at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544) [sshexec] at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526) [sshexec] Caused by: java.lang.ClassNotFoundException: uk.co.caprica.picam.PictureCaptureHandler [sshexec] at java.net.URLClassLoader.findClass(URLClassLoader.java:381) [sshexec] at java.lang.ClassLoader.loadClass(ClassLoader.java:424) [sshexec] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) [sshexec] at java.lang.ClassLoader.loadClass(ClassLoader.java:357) [sshexec] ... 7 more