We are trying to build a standalone Java Image application that would read the camera, process the image, and post data to the Smart Dashboard. For debugging we would like to read in one of the sample images. However our code crashes using the RGBimage(“filename.jpg”) with a class not found exception.
We haven’t found any examples of standalone java applications. Only ones that use the cRIO. Can anyone help?
/**
* @param args the command line arguments
*/
public static void main(String] args) {
// TODO code application logic here
ColorImage image; // next 2 lines read image from flash on cRIO
try { image = new RGBImage("/10ft2.jpg");
} catch (NIVisionException ex) {
logger.getLogger(JavaImageSample.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
Here is the debugger output showing we error on the line
image = new RGBImage("/10ft2.jpg");
We have also tried defining the complete path to the image too.
debug:
Exception in thread “main” java.lang.NoClassDefFoundError: com/sun/cldc/jna/TaskExecutor
at edu.wpi.first.wpilibj.image.NIVision.<clinit>(NIVision.java:29)
at edu.wpi.first.wpilibj.image.Image.<init>(Image.java:24)
at edu.wpi.first.wpilibj.image.ColorImage.<init>(ColorImage.java:16)
at edu.wpi.first.wpilibj.image.RGBImage.<init>(RGBImage.java:32)
at javaimagesample.JavaImageSample.main(JavaImageSample.java:27)
Caused by: java.lang.ClassNotFoundException: com.sun.cldc.jna.TaskExecutor
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
… 5 more
Java Result: 1
BUILD SUCCESSFUL (total time: 18 seconds)
You can’t just take WPIlibJ programs set up to run under the SquawkVM on the cRIO and run them under a regular VM on Windows. You would need a SquawkVM for Windows and significant rewriting of the code to support this. To do image processing on a PC check out the Smart Dashboard vision extension.
Note I did try the program using Netbeans 6.9.1 and that fails too. It makes sense that the libraries are written for the Alpha on the cRIO. So much for JAVA portability.