Class Not Found Exception

I’m trying to create a library that uses another library.

When I’m trying to run the application that uses the library I’m getting this exception:

image

demo-lib:

build.gradle (demo-lib):

plugins {
    id 'java'
    id 'java-library'
}

group = 'org.example'
version = '1.0.0'

repositories {
    mavenCentral()
}

dependencies {

}

DemoLib.java:

package org.example.demolib;

public class DemoLib {
    public static void useDemoLib() {
        System.out.println("demo-lib");
    }
}

demo-jar:

build.gradle (demo-jar):

plugins {
    id 'java'
    id 'java-library'
}

group = 'org.example'
version = '1.0.0'

repositories {
    mavenCentral()
}

dependencies {
    implementation files("../demo-lib/build/libs/demo-lib-1.0.0.jar")
}

DemoJar.java:

package org.example.demojar;

import org.example.demolib.DemoLib;
public class DemoJar {
    public static void useDemoJar() {
        DemoLib.useDemoLib();
        System.out.println("demo-jar");
    }
}

demo-app:

build.gradle (demo-app):

plugins {
    id 'java'
    id 'application'
}

group = 'org.example'
version = '1.0.0'

repositories {
    mavenCentral()
}

dependencies {
    implementation files("../demo-jar/build/libs/demo-jar-1.0.0.jar")
}

application {
    mainClass = 'org.example.demoapp.Main'
}

Main.java:

package org.example.demoapp;

import org.example.demojar.DemoJar;
public class Main {
    public static void main(String[] args) {
        DemoJar.useDemoJar();
    }
}

Please never share screenshots of text anywhere unless you want to show more than the text like colors or IDE annotations. Screenshots are harder to read especially on mobile, much harder to copy from, and nearly impossible to search for.

Besides that, you missed to tell what you do and you also missed to ask any question.

Besides that, using files(...) or fileTree(...) as dependencies is in almost all cases a very bad idea.
That usually just leads to various problems (probably not your problem though, but in general).
If those a are three projects in one build, use a project(...) dependency.
If they are three separate builds, depend on them using coordinates and combine the builds using composite build feature or by publishing the dependency projects somewhere before consuming them.