Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Ground Controller Lvl 1
Message 1 of 2

Reading QR code using Webcam in Java

i am writing a code to read QR code in java (Netbeans IDE) using Webcam, the code was free from syntax error but the code refuse to build. The code is use is: -

 

Webcam webcam = Webcam.getDefault();
webcam.open();

Result result = null;
BufferedImage image = null;

if (webcam.isOpen()) {
//if ((image = webcam.getImage()) == null) {
//continue;
//}

LuminanceSource source = new BufferedImageLuminanceSource(image);
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
try {
result = new MultiFormatReader().decode(bitmap);
} catch (ReaderException e) {

}
}

if (result != null) {
System.out.println("QR code data is: " + result.getText());
}

 

The error is: -

java.lang.VerifyError: Cannot inherit from final class
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" C:\Users\jh\AppData\Local\NetBeans\Cache\8.2\executor-snippets\run.xml:53: Java returned: 1

 

Please how do i resolve this error. thank you

1 Reply
Commander Lvl 3
Message 2 of 2

Re: Reading QR code using Webcam in Java

Some clarification about the error message you are getting: https://stackoverflow.com/a/18138276

 

Also, next time please post your code or console output inside a code block or a GitHub Gist (https://gist.github.com/). That makes it a bit easier for all of us.


- Mark