Exception ImageReadException
See original GitHub issuei am using netbeans and buil , run operations are successful but I am getting following error while running jar file
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/sanselan/ImageReadException
at com.machinezoo.sourceafis.FingerprintTemplate.create(FingerprintTemplate.java:96)
at com.machinezoo.sourceafis.MainClass.main(MainClass.java:47)
Caused by: java.lang.ClassNotFoundException: org.apache.sanselan.ImageReadException
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 2 more
My main class
package com.machinezoo.sourceafis;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
public class MainClass {
public static final String ANSI_RESET = "\u001B[0m";
public static final String ANSI_BLACK = "\u001B[30m";
public static final String ANSI_RED = "\u001B[31m";
public static final String ANSI_GREEN = "\u001B[32m";
public static final String ANSI_YELLOW = "\u001B[33m";
public static final String ANSI_BLUE = "\u001B[34m";
public static final String ANSI_PURPLE = "\u001B[35m";
public static final String ANSI_CYAN = "\u001B[36m";
public static final String ANSI_WHITE = "\u001B[37m";
public static void main(String[] args) {
try {
String probPath = "/var/www/java/robertvazan-sourceafis-java-6db53f9947c0/resources/prob.tif";
String candidatePath = "/var/www/java/robertvazan-sourceafis-java-6db53f9947c0/resources/101_7.tif";
System.out.printf("The culprit: ");
byte[] probeImage = Files.readAllBytes(Paths.get(probPath));
byte[] candidateImage = Files.readAllBytes(Paths.get(candidatePath));
File folder = new File("resources");
File[] listOfFiles = folder.listFiles();
for (int i = 0; i < listOfFiles.length; i++) {
if (listOfFiles[i].isFile()) {
System.out.println("File " + listOfFiles[i].getName());
} else if (listOfFiles[i].isDirectory()) {
System.out.println("Directory " + listOfFiles[i].getName());
}
}
FingerprintTemplate probe = new FingerprintTemplate().dpi(500).create(probeImage);
List<UserDetails> candidates = new ArrayList<>();
UserDetails candidate = new UserDetails();
candidate.id = 1;
candidate.name = "XYZ";
candidate.template = new FingerprintTemplate().dpi(500).create(candidateImage);
candidates.add(candidate);
UserDetails culprit = candidate.find(probe, candidates);
if (culprit == null) {
System.out.printf("unable to find match");
} else {
System.out.printf("The culprit: " + ANSI_RED + "%s", culprit.name);
}
} catch (IOException e) {
// e.printStackTrace();
System.out.printf("Exception occurred");
}
}
}
class UserDetails {
int id;
String name;
FingerprintTemplate template;
UserDetails find(FingerprintTemplate probe, Iterable<UserDetails> candidates) {
FingerprintMatcher matcher = new FingerprintMatcher()
.index(probe);
UserDetails match = null;
double high = 0;
for (UserDetails candidate : candidates) {
double score = matcher.match(candidate.template);
if (score > high) {
high = score;
match = candidate;
}
}
double threshold = 40;
return high >= threshold ? match : null;
}
}
Issue Analytics
- State:
- Created 5 years ago
- Comments:14 (7 by maintainers)
Top Results From Across the Web
Class ImageReadException - Apache Commons
A custom exception thrown when an ImageParser or other utility encounters a format-violation, non-supported element, or other condition that renders image ...
Read more >org.apache.commons.imaging.ImageReadException java ...
A custom exception thrown when an ImageParser or other utility encounters a format-violation, non-supported element, or other condition that renders image data ...
Read more >ImageReadException Class - Atalasoft
Occurs when an exception is serialized to create an exception state object that contains serialized data about the exception. (Inherited from Exception.) Top....
Read more >commons-imaging/ImageReadException.java at master - GitHub
... Sanselan) is a pure-Java image library - commons-imaging/ImageReadException.java at ... A custom exception thrown when an ImageParser or other utility.
Read more >String org.apache.commons.imaging.ImageReadException:4 ...
Lucee Dev · String org.apache.commons.imaging.ImageReadException:4 components are invalid or unsupported · dev ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Aha. I missed the part about JAR. I thought you get this exception when running the code in NetBeans. That means incorrect JAR packaging. Dependencies are not included in JAR. This is not a SourceAFIS issue then. You need to figure out how to include Maven dependencies in the JAR file when building in NetBeans. That’s a NetBeans question.
Could you share the solution to your problem? I’m having the same error message.