1

I'm new to Java and Maven , I tired to run a simple program using SoureceAFIS library. The code compiles well with no errors but when i run it it shows

java.lang.NoClassDefFoundError : java.lang.NoClassDefFoundError: com/machinezoo/sourceafis/FingerprintTemplate

App.java

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

import com.machinezoo.sourceafis.FingerprintTemplate;

public class App 
{
    public static void main( String[] args )
    {
        try 
        {
            byte[] probeImage = Files.readAllBytes(Paths.get("1.jpg"));
            byte[] candidateImage = Files.readAllBytes(Paths.get("2.jpg"));

            FingerprintTemplate probe = new FingerprintTemplate()
                .dpi(500)
                .create(probeImage);

            FingerprintTemplate candidate = new FingerprintTemplate()
                .dpi(500)
                .create(candidateImage);        
        } 

        catch (IOException e) {
          System.out.println(e);
        }

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.veevo.fvs</groupId>
  <artifactId>fvs</artifactId>
  <packaging>jar</packaging>
  <version>1.0</version>
  <name>fvs</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
  </properties>

  <dependencies>

    <!-- SourceAFIS -->
    <dependency>
    <groupId>com.machinezoo.sourceafis</groupId>
    <artifactId>sourceafis</artifactId>
    <version>3.3.1</version>
    </dependency>

    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>

  </dependencies>
</project>

Project tree structure:

.
├── 1.jpg
├── 2.jpg
├── pom.xml
├── src
│   ├── main
│   │   └── java
│   │       └── com
│   │           └── veevo
│   │               └── fvs
│   │                   └── App.java
│   └── test
│       └── java
│           └── com
│               └── veevo
│                   └── fvs
│                       └── AppTest.java
└── target
    ├── classes
    │   └── com
    │       └── veevo
    │           └── fvs
    │               └── App.class
    ├── fvs-1.0.jar
    ├── generated-sources
    │   └── annotations
    ├── generated-test-sources
    │   └── test-annotations
    ├── maven-archiver
    │   └── pom.properties
    ├── maven-status
    │   └── maven-compiler-plugin
    │       ├── compile
    │       │   └── default-compile
    │       │       ├── createdFiles.lst
    │       │       └── inputFiles.lst
    │       └── testCompile
    │           └── default-testCompile
    │               ├── createdFiles.lst
    │               └── inputFiles.lst
    ├── surefire-reports
    │   ├── com.veevo.fvs.AppTest.txt
    │   └── TEST-com.veevo.fvs.AppTest.xml
    └── test-classes
        └── com
            └── veevo
                └── fvs
                    └── AppTest.class

32 directories, 15 files

when i run it using

habib@Habib-PC:~/Documents/Projects/Veevo/fvs$ java -cp target/fvs-1.0.jar com.veevo.fvs.App
Exception in thread "main" java.lang.NoClassDefFoundError: com/machinezoo/sourceafis/FingerprintTemplate
    at com.veevo.fvs.App.main(App.java:22)
Caused by: java.lang.ClassNotFoundException: com.machinezoo.sourceafis.FingerprintTemplate
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:185)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:496)
    ... 1 more

What am I doing wrong? It seems like Maven does not install my dependency.

Khaalidi
  • 138
  • 10

0 Answers0